40
Last seen 1 day ago
Member for 9 years, 11 months, 4 days
Difficulty Advanced
Hi, as phrases is a sequence of strings you don't need str(x) so you could write:
",".join(phrases)
More
Hi, some advices:
# 1. You can use negative indexes
array[len(array) - 1] == array[-1]
# 2. You don't need the z variable:
array[::2] == array[:len(array):2]
# 3. sum is not a good variable name, as there's a built-in function called __sum__.
More
Hi, the lambda superfluous. In this case you could write:
return sorted(number_array, cmp=abs)
More
It's a bit "overlamdized" :)
A small tip:
# Change b, c in a way you don't need to use not
# and then you can write:
return a(data) and b(data) and c(data)
# what you could transform
return all((a(data), b(data), c(data)))
# and finally:
return all(f(data) for
More
This could be a cool one-liner, if you omitted _pattern_ and changed def to lambda. [Here](http://www.checkio.org/mission/fizz-buzz/publications/suic/python-3/bobrikos-one-lines/) it is. Thanks for inspiration.
More
Hi, you don't need to import math power, because ** is the same, so:
return int(array[n] ** n)
More
Hi, just one thing: On lines 20, 21 _False_ can be used instead of _None_. After that you can simplify lines 25, 28 e. g:
letter in WOVELS and not vow
# instead of:
letter in VOWELS and vow in [False, None]
More
Hi, this solution is fine. I have two comments:
1. It's a common "beginner's design pattern" :)
# to use:
if x:
return True
else:
return False
# instead of:
return x
2. Line two contains three times the same pattern (_and re.(someregex, data)_) => dupli
More
I've been playing a bit more with your solution and I've come up with [this](http://www.checkio.org/mission/monkey-typing/publications/suic/python-3/another-one-liner/). Thanks for inspiration.
More
Hi, in fact there's no problem with solution. You could shorten it a bit :)
1. You don't the if part of the list comprehension as True == 1 and 0 == False.
2. And as you don't use _s_ anywhere else omit the s variable:
return sum([text.lower().count(word) for word in words])
More
Hi,
You probably forgot to remove return True or False.
You could also clean up your code a bit.
There are a few "beginner design patterns" :)
1. This is quite common:
return result
# is the same as
if result:
return True
else:
return False
2. In a
More
Hi, two things:
1. This is unnecessary:
if a % 3 != 0 and a % 5 != 0:
return "{}".format(a)
# The a % 3 != 0 and a % 5 != 0 is met at that point.
2. The standard way of convert something to string is simply using __str__(x). So you could write:
return str(a) #
More