40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, `bin()` returns a __`str`__ so `str()` is redundant.
More
Hi, you don't need `lambda`. _abs()_ is a function, so:
return sorted(numbers_array, key=abs)
is enough.
More
This will evaluate everything before it's checked with `any()`. It can be avoided by chaining `or`s.
More
Hi, when you first join the phrases, you can replace the words all at once:
return ",".join(phrases).replace('right', 'left')
More
Hi, as you don't use the index here:
for index, value_b in enumerate(sequence[index:]):
# you can write:
for _, value_b in enumerate(sequence[index:]):
More
Hi,
# Instead of this:
if len(queue) == 0:
continue
queue.pop(0)
# you could write this:
if queue:
queue.pop(0)
More
Hi,
1. look at _filter()_ and _str.join()_.
2. __str__ is immutable in Python, therefore is not the best type for accumulation.
More
Hi, why not:
def checkio(words_set):
for x in words_set:
if x.endswith(tuple(words_set - {x})):
return True
return False
# or:
def checkio(words_set):
return any(x.endswith(tuple(words_set - {x})) for x in words_set)
More
Hi, all `...if...else...` are redundant, e. g.:
if operation == "conjunction":
return x and y
More
Hi,
1. There's an unnecessary semicolon :)
2. You could replace lines 5-8 to using all with this:
ok = all(state[pipe_num] for pipe_num in pipe_numbers)
# then you don't even need the ok variable as you could write this:
if all(state[pipe_num] for pipe_num in pipe_numbers):
More
Hi,
1. Look at _set()_.
2. Line 11 is not Pythonic and you can replace lines 11-13 with:
return not my_dict
More
Hi,
1. `"".join(text)` is useless, it does nothing.
for i in text: # is enough
...
2. Look at _filter()_.
More
Hi, have at [_calendar.isleap()](https://docs.python.org/3/library/calendar.html?highlight=calendar.isleap#calendar.isleap) and [calendar.day_name](https://docs.python.org/3/library/calendar.html?highlight=calendar.isleap#calendar.day_name).
More