40
suic
16 39 57
9964/ 10664
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Best reviews / Newest reviews
First-eugene128736871
Hi, it's kinda verbose: 1. `== None` is redundant. 2. You can use _all()_ instead of those `if`s. 3. In each if condition you have the same pattern. return all(re.search(rgx, d) for rgx in ("^.{10,}$", "[0-9]+", "[a-z]+", "[A-Z]+")) More
First-eugene128736871
Hi, 1. _max()_ and _dict()_ are a built-in functions. 2. Look at _sorted_, e. g.: `alpha = sorted(dict)` 3. Even if Python's exceptions are not expensive, lines 2-9 are quite ugly. 4. Look at __collections.Counter__. I've played with your code. Result is [here](http://www.checkio.org/mission/most- More
First-eugene128736871
Hi, have you heard about extended slices? More
First-Rita
Hi, a few comments: 1. `else: pass` branches are redundant. They don't do anything. 2. You could write `sum += stack[-1]` instead of `sum = sum + stack[len(stack)-1]`. 3. and also `if stack:` instead of `if len(stack) > 0`. P. S.: It's better to avoid `sum` as variable name. It's a useful built-in More
First-Rita
Hi, 1. `else: continue` is redundant. 2. You could use _any()_ or _all()_ + generator expression. More
First-LetterRip
Hi, you could use _any()_: any(c1.endswith(c2) or c2.endswith(c1) for c1, c2 in combinations(words_set, 2)) More
First-levor2384
Hi, you could write: if word1 != word2 and word1.endswith(word2): return True or even use _any()_ with _generator expression_. More
2 loops + endswith-neitsa
Hi, you could write: if i != n and o.endswith(w): return True More
First-pbeesley 1
Hi, 1. You could write alphabet as a string: "abcdefghijklmnoprstuvwxyz" as __str__ is is iterable. 2. The if is redundant as: if condition: return True else: return False # is the same as return condition More
First-MichaelAzar
Hi, I have a few comments: 1. Line 2-4 for are useless. On line 8 you use x.isalpha() which returns False for white spaces, so you don't need to remove them previously. All you need to preserve is this: text = text.lower() # and then replace no_white with text for x in text: More
First-Benjamin.michelland
Hi, let me deduce from your code first: 1. You're comming from the C-world. 2. You speak French. I have a few pieces of advices: 1. Forget about semicolons in Python :) 2. Look at [_String Methods_](https://docs.python.org/3.5/library/stdtypes.html?highlight=str#string-methods). More
First-puay
Hi, _bin()_ return __str__ so `str(bin_num)` is redundant. As `bin(number)` is a __str__ you can use _str.count()_ method. More
Back to front-puay
Hi, 1. Look at _divmod()_. 2. Look at [this](https://docs.python.org/3.4/library/stdtypes.html#truth-value-testing). def checkio(number): multiple=1 while number: number, digit = divmod(number, 10) if digit: multiple *= digit return multiple More
First-Jalk65
Hi, 1. Why not?: if len(array) > 0: # or even: if array: # and: for i in array[::2]: # instead of for i in array[0: len(array): 2]: 2. Look at _sum()_: # sum of even elements: sum(array[::2]) More
if, elif, else-Alexona 1
Hi, why not?: elif op == 'exclusive': return x != y More
First-tehtactics19
Hi, that `else: print str(number)` is redundant. More
First-tehtactics19
Hi, `len(array)` is redundant. More
First-daswerth
Hi, instead of lines 14-17 you could write: return brackets == [] # or return not brackets More
First-daswerth
You like typing :) import re VOWELS = "[AEIOUY]" CONSONANTS = "[BCDFGHJKLMNPQRSTVWXZ]" r = re.compile(r'\A({0}?({1}{0})*{1}?){2}\Z'.format(VOWELS, CONSONANTS, '{1}'), re.I) def checkio(text): return sum(bool(len(w) > 1 and r.match(w)) for w in re.split(r' More
First-AndreyDorofeyev 1
Hi, 1. You can import string.ascii_lowercase instead of `abc`. 2. `... if ... else ...` is redundant. return all(w.lower() in text.lower() for w in abc) More