40
Last seen 1 day ago
Member for 9 years, 11 months, 4 days
Difficulty Advanced
Hi,
1. Line 3: `[]` are redundant.
2. Look at `Counter` in `collections` module.
More
Hi,
1. _sum()_ is built-in function, don't redefine it.
2. Look at _enumerate()_.
3. Line 13 is useless.
4. Lines 10-12 should be right after the function definition.
5. `sequence` is iterable and _list()_ is redundant.
More
Hi,
ad `a`: You don't need list() as `phrases` is iterable => You don't need that variable at all.
ad `b`: x is a __str__ so _str()_ is redundant. And also as `phrases` is __tuple__ of __str__ you can write:
b = ",".join(phrases)
and `c`: You don't need it. You can chain methods:
return
More
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
Hi,
1. on lines 5, 8, 11, 20 `[]` are redundant.
2. in fact you don't need those `check_` functions.
More
Man, this is way to complicated... Look at [_sorted()_](https://docs.python.org/3.4/library/functions.html#sorted).
More
Hi, instead of that `lambda` in `cleanup` you could use _str.isalnum()_ (or a fancier solution: import _filterfalse()_ from itertools).
More
Hi,
1. _sum()_ is a built-in function, do not redefine it.
2. Look at negative indices e. g. `array[-1]`
3. Look at _extended slices_ e. g. `array[::2]` gives you the even elements.
More
Hi,
1. lines 13 to 15 are useless: `return temp`
2. Don't use semicolons in Python.
3. Look at _list comprehensions_ and _generator expressions_.
More
Hi,
1. __str__ is a name of type and also there's a _str()_ built-in function, which you shouldn't redefine.
2. __str__ has _str.isupper()_ method.
3. With _str.join()_ method you can concatenate strings.
4. __str__ is iterable, therefore:
for i in text:
if i >= 'A' and i <= 'Z':
More
Hi, _min()_ and _max()_ are built-in functions. Do not redefine them:
return max(args) - min(args)
More
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
Hi, why not:
return (game_result[0][0]==who and ...)
That `if...else` is redundant.
More