40
suic
16 39 57
9964/ 10664
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Best reviews / Newest reviews
First-l-vincent-l
Hi, in Python you can write it this way: 97 <= ord(c) <= 122 More
First-l-vincent-l
Hi, 1. Look at _str.endswith()_. 2. Look at `operator` module. 3. In this a _generator expression_ or list comprehension would be faster than _map()_ and IMHO cleaner: [x != y and len(x) > len(y) and x[-len(y):] == y for x, y in itertools.product(words_set, words_set)] More
First-l-vincent-l
Hi, look at _timedelta.days()_ method. More
First-l-vincent-l
Hi, look at _min()_ and _max()_ built-in functions. More
First-l-vincent-l
Hi, 1. _list()_ is redundant. 2. You could use `&` operator for set intersection. More
First-l-vincent-l
Hi, lambda is redudant. _abs()_ is a function: return sorted(numbers_array, key=abs) # pay attention that it is abs and not abs() More
First-neophobias
Hi, 1. You don't need the `result` variable. 2. Look at _all()_, e. g. you can write this instead of line 8: if all(j.isalpha() for j in wlist[i:i+3]): 3. You don't need that `else` branch. 4. Look at _any()_. Using it you can refactor lines 3 and 6-10 like this: return any(all(j.is More
First-neophobias
Hi, 1. all those inner `if...else`s are redundant, e. g.: return not (x == 1 and y == 0) # for lines 13-16 2. you don't have to enumerate the cases. Just use `or`, `and` and `not` built-ins and `==` and `!=` operators. More
First-neophobias
Hi, 1. `== True` is redundant as _str.isupper()_ returns __bool__. 2. __str__ is immutable, therefore it is not the best type for accumulation. 3. Last but not least __str__ is _iterable_ so you could write: for i in text: if i.isupper(): word += i # or even better More
First-marroyo
Hi, `message` is redundant: return "".join(i for i in text if i.isupper()) More
Boolean Algebra-marroyo
Hi, you don't need all those internal `if...else`s e. g.: if operation == "equivalence": return x == y More
First-e2dyToe
Hi, 1. you don't need _re_: counts = Counter(filter(str.islower, text.lower())) 2. you don't need `max_counts`: return sorted(x for x in counts if counts[x] == max(counts.values()))[0] More
With another function-sliziky
Hi, _sorting_ function is redundant: return sorted(numbers_array, key=abs) More
First-Freezen
Hi, you can write: sum(grid...). `[]` is redundant. More
First-SoooSeriooous 1
Hi, lines 20 and 21 are redundant. In fact all that `if...else` is redundant, as it's a precondition. More
First-Freezen
Hi, you can use _str.count()_ for this, but with counter is probably faster. More
Experimenting with the Counter Class-zero_loss 1
Hi, 1. For line 3 you can use _filter()_: text = filter(str.isalpha, text.lower()) 2. In fact you don't need the `text` variable: common = Counter(filter(str.isalpha, text.lower())) 3. With _sorted()_ you can get rid of lines 5 and 6: return sorted(x for (x,y) in common if More
First-aisilunya
Hi, 1. `== True` is redundant. _str.isupper()_ returns __bool__. 2. `ch` is a __str__ so _str()_ on line is redundant. 3. Look at _generator expressions_ and the _str.join()_ method. More
For is the best loop :D-JanKaifer
Hi, 1. _any()_ instead of lines 40-43? return any(first in i and second in i for i in groups) 2. `names = net.keys()` 3. `net = {name: {} for rel in new for name in rel}` etc. More
First-Pauls
Hi, 1. `bstr` is redundant. 2. You don't need _str()_ as _bin()_ returns __str__. More