40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, you do the same thing len(phrases) times, why?
def left_join(phrases):
output = ",".join(phrases)
output = output.replace('right', 'left')
return output
# is enough.
# And now get rid of output variable as you don't need it:
return ",".join(phrases).re
More
Hi, what's the point of the for loop? You do the same thing len(args) times.
# this is enough:
def checkio(*args):
if not args: return 0
return max(args) - min(args)
More
Hi, ... good, evil... that's funny :) but line 10 isn't:
return ",".join(curse) # is enough
More
Hi, the print statements are useless. If you really want to comment your code, then _comment_ and don't write print statements like these.
More
Hi, float division in boolean algebra task, why?
1. Line 13: return x == y
2. Line 11: return x != y
3. Line 7: return x or y
4. Line 5: return x and y
Conclusion: You don't need to import math.
More
Hi, a few comments:
1. You don't the for loop and _Capitals_ variable:
return "".join(ListOfCapitals) # str.join() in action
2. You don't need re:
# verbose :)
res = []
for letter in text:
if letter.isupper():
res.append(letter)
return "".join(res)
More
Hi,
1. Look at negative indices: A[len(A)-1] == A[-1].
2. You don't need to sort A when it's empty.
3. Instead of:
if A == []:
...
# you can write:
if not A:
...
More
Hi,
1. test if string is not a digit/number with try...except, why?
# There are methods like
# str.isnumeric() or str.isalpha() for that.
2. for each?
for w in splitted_words:
if w.isalpha():
tf_string += 'True'
else:
tf_string += 'False'
More
Man, ...
else:
S = S
Why? You don't need that branch at all.
Few tips:
1. Negative indices:
array[len(array)-1] == array[-1]
2. You can write x += 1 instead of x = x + 1.
3. Look at _sum()_ function.
return sum([::2]) * array[-1]
More
Hi,
1. Lines 6-8 are redundant.
2. Lines 13-16 are redundant:
return len(a) and len(b) and len(c)
# or even
return a and b and c
3. You don't the `else` branch on lines 17 and 18.
def checkio(password):
if len(password) < 10: return False
a = re.findall("[a-z]+
More
Hi, it is not so ugly, but it needs some cleanup:
1. You could do it with less parentheses and less steps. E. g. lines 16-18:
# Options:
s = (len(data) - 1) / 2 # is enough
s = int((len(data) - 1) / 2) # merge 16-17
s = data[int((len(data) - 1) / 2)]
More
Hi, this is way to complicated:
1. Look at `^` operator.
2. On line 7 you don't need `[]` and `...if...else`
More
Hi,
1. __str__ is iterable. So `text = text.lower()` is enough.
2. It should be `x not in text`.
3. You could use _any()_ built-in function for this mission.
More