40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, you don't need bool. Try in Python REPL:
>>> number = 1
>>> type(number % 3 == 0) # it's already a bool
More
Hi,
first of all I don't want to discourage you. It's nice that you use __str__ methods instead of _re_ :)
I would show you some of the beauty of Python. With a basic set of built-in functions you can avoid a lot of noise and code duplication.
1. You don't need the "else-cascade" :)
def ch
More
Hi,
1. there's quite a lot of duplication there. On lines 4-9 you do two times the same thing.
2. You don't the convert ..._words to lists. __str__ is iterable:
def verify_anagrams(first_word, second_word):
first_word = first_word.strip().lower()
second_word = second_word.str
More
Hi, what is the point of line 7, 8? You also don't need the _numbers_ (_args_ is iterable), _vmax_ and _vmin_ variable. This is enough:
def checkio(*args):
if len(args) >= 2:
return max(args) - min(args)
else:
return 0
More
Hi, sorry but this solution is for thumbs down.
1. To many _ifs_.
return len(args) and max(args) - min(args) # that's all
2. All the
else:
pass
branches are pointless. You don't need them.
3. Why this way?:
if len(args) == 0:
return 0
elif len(
More
Hi, else branch and bool are redundant ...
I've played with that a bit. [Here](http://www.checkio.org/mission/house-password/publications/suic/python-3/grigoriytretyakovs-shortened-using-evil-eval/) is the result.
More
Hi, in fact you don't need _re_ for this mission. You can replace for loop with _all()_ and _if_ with _and_:
return len(data) > 9 and all(re.search(r, data) for r in ('[0-9]', '[A-Z]', '[a-z]'))
More
Hi, you don't need the lambda. _abs_ is a function and _key_ has to be a function:
return sorted(numbers_array, key=abs)
More
Hi, you don't need the last if:
return second in friends[first] # is enough
More
Hi, you don't need the tuple:
more, less = max(args), min(args)
# and in fact you don't need more and less
return max(args) - min(args)
More
Hi, in this case you don't need lambda. You can import mul from operator or basically use int.\_\_mul\_\_:
return reduce(int.__mul__, [int(x) for x in str(number) if x!= '0'])
# another approach:
return reduce(int.__mul__, filter(None, map(int, str(number))))
More