40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, in fact you don't need to import string here. Look at str.isdigit, str.islower and str.isupper methods.
More
Hi, you can write:
return sum(word.lower() in text.lower() for word in words)
More
Hi,
1. there's also 'str.isalnum()`.
2. I would move the len(data) < 10 to the beginning, once data is to short, you don't need to make the rest of the checks.
3. `bool` is redundant and it's not a good variable name as it's a name for a built-in type.
More
Hi, that if is redundant:
return sorted(first_word.lower()) != sorted(second_word.lower())
More
Hi, [] is redundant. _filter()_ built-in would be better here:
return ''.join(filter(str.isupper, text))
More
Hi, this is "overparenthesized" :D
# E. g.:
bin_n = bin(n)[2::][::-1]
bin_m = bin(m)[2::][::-1] + diff_len * "0"
More
Hi, look at documentation for _sorted()_. Sorted has _key_ argument, which is quite useful.
More
Hi, lines 2-4 are redundant, just remove them. _numbers_array_ is iterable by itself so you don't have to convert it to list.
The pattern in lines 2-4 you can usually replace with a list comprehension/generator expression (look at [this](https://docs.python.org/3/howto/functional.html#generator-exp
More
Hi, `letters` is redundant.
len({char for char in text.lower() if char in string.ascii_letters}) == 26
More
Hi, in python you don't need auxiliary variable to swap values of two variables. E. g. to swap the values of a and b it's enough to do this:
a, b = b, a
More
Hi,
1. Notice that you do many steps twice.
2. The last if is unnecessary:
return liste1 == liste2
More
Hi, `listToString` is reinventing the wheel. Look at [_str.join_](https://docs.python.org/3.5/library/stdtypes.html?highlight=str.join#str.join).
More
Hi, when you return the same thing from two branches you don't need two branches.
More
Hi, you could use str.isupper instead of t in ascii_uppercase. In that case you don't need to import ascii_uppercase.
More