40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, [] and ...if...else are redundant. You can write:
return sum(w in text.lower() for w in words)
More
Hi, once result is True, you don't need to continue. In fact you don't need `result` at all:
if eu >= 3:
return True
return False
More
Hi,
1.that last `if` and all the `== True` checks are redundant e. g.:
return all((a, b, c, d))
2. `data.split()` does nothing.
3. All `range (0, len(data) - 1)` are redundant:
for x in data:
...
etc.
More
Hi, ad my down votes:
1. What is this? Exercise in obfuscation?
return "".join(filter(str.isupper, texte)) # that's all
# but even a more basic way using for loop plus some accumulator list
# would be much better.
2. Even if exceptions are cheap in python, that `try:...except...: bre
More
Hi,
1. _letter.isupper()_ returns __bool__ so == 1 is redundant.
2. It would be much shorter with filter (in Py 2.7 even shorter than in Py 3.3):
return filter(str.isupper, text)
More
Hi,
1. __str__ is a built-in type => don't use str as variable name.
2. That `print(str)` is unecessary.
3. `str.istitle()` is a __bool__ so `== True` is redundant.
More
Hi, `cap` and `message` are redundant:
return ''.join(x for x in text if x.isupper())
# with filter() it would be nicer and shorter:
return filter(str.isupper, text)
More
Hi, those nested `if`s are redundant. E. g.:
elif operation == "implication":
return x == 0 or x == 1 and y == 1
More
Hi, you can write this instead of the last if:
return index and triangls_num[index[0]:index[1]+1]
More
Hi, all the nested `if`s are redundant, e. g.:
if operation == "equivalence":
return x == y
# or
if operation == "conjunction":
return x and y
# etc.
More
Hi, man __8 from 9 lines are redundant__.
1. Remove _print()_ before publishing.
2. Line 6 is redundant. __str__ has _str.count()_ method.
3. You don't need `k` variable:
return bin(number).count('1') # that's all
More