40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, I agree with previous comment, but you can also significantly shorten you existing code e. g.:
# assign game_result to a shorter variable
gr = game_result
# remove all the _row, _column, _diag variables as you don't need them (see below),
# replace game_result with gr and crea
More
Hi, "crystal clear" but creative :)
1. `map(lambda x:...)` is not good practice.
2. Alternative way to compute signum: `def signum(x): return (x > 0) - (x < 0)`
More
Hi, look at [__collections.Counter__](https://docs.python.org/3.5/library/collections.html?highlight=counter#collections.Counter).
More
Hi, I have a few comments:
1. Look at str.islower, str.isupper, str.isdigit.
2. Remove _print_ before publishing.
3. You could omit the last if, as your condition is by itself a boolean:
# Instead of
if boolean_condition:
return True
else:
return False
# you
More
Hi, as _three >= 3_ is already a bool you don't need the last if:
return three >= 3
More
Hi, I have two comments:
1. Look at slices. Using slices is shorter and more Pythonic than while this way.
2. Why not sum += array[i]?
More
Hi, two things:
1. m is redundant, you could directly str(number) in for loop:
for n in str(number):
...
2. You can write t *= int(n).
More
Hi, I have two comments:
1. letter is a __str__ so you could write:
if letter.isdigit(): d = True # and so on
2. Move the _if d and u and l: return True_ inside the for loop. Once all of d, u and l are True you don't need to continue.
More
Hi, in python you can join methods therefore you could write it like this:
return ','.join(phrases).replace('right', 'left')
More
Hi, I have a few comments:
1. Don't use _min_ as variable name. _min_ as a built-in function.
2. taille is redundant and you could immediately return on line 6:
if len(data) < 10:
return
3. Move line 18 and 19 inside the for loop. Once you meet all three conditions you can return.
More
Hi, look at slices in python:
# Lines 7-9 you could replace with:
suma = sum(array[::2])
You could also write:
if array:
...
# instead of:
if len(array) > 0:
...
Look at [this](https://docs.python.org/3/library/stdtypes.html#truth-value-testing).
More
Hi, this is a bit "selfobfuscating" :)
1. Line 4: True if ... else False is redundant.
2. Look at __set__ type in Python:
# You could replace this:
reduce(lambda x, y: x+y if x[-1] != y else x, sorted_lst)
# with:
set(sorted_list)
3. You don't need the alphabet val
More
Hi, interesting approach :) I have two comments:
1. Look at negative indexes:
# You could write:
array[-1]
# instead of:
array[len(array) - 1]
2. Look at __in__ in Python. E. g.:
# You could write:
div5 = s[-1] in "50"
# instead of:
div5 = s[len
More
Hi, you could write _fibo_check_ like this:
def fibo_check(numb):
return numb in fibonacii(numb + 1)
1. The _if_ is redundant as numb in ch is already a boolean.
2. ch don't have to be a list as you could iterate over generator.
3. As you use _ch_ only once you could easily eliminate
More
Hi, I have two comments:
1. I hope, you've just forgot to remove the semicolon on line 3 :)
2. Look at _sum_ built-in function e. g.:
# Lines 5-8 you could replace with:
k = sum(array[::2])
# or the whole else block:
return sum(array[::2]) * array[-1]
# That's it :)
More
Hi, I have two comments:
1. In fact you don't need the else branch on line 11:
if len(data) < 10:
return False
# unindent the rest by one level.
2. On lines 4-9 you have three time the same pattern. You can extract the pattern and eliminate repetition.
You have:
if re.
More
Hi, on thing: _lambda_ and _map_ are redundant:
# You can join the phrases first which will result in one big string.
s = ','.join(phrases)
# And as s is a string you can directly call its replace method.
return s.replace('right', 'left')
# Finally: As you can chain
More
Hi, line 5 is useless as on the next line you assign a different value to _new_. In fact you can eliminate _new_ completely i. e. replace _new_ with _phrases_ on line 7.
More