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-anonymorf 1
Hi, 1. Lines 8-16 reminds me: ["Empty spaces - what are we living for..."](https://vimeo.com/19166601) :D 2. `n` and `y` are redundant and return value doesn't have to be parenthesized. 3. Line 4: `arr[0:len(arr):2] == arr[::2]` and for non-empty lists: `arr[len(arr)-1] == arr[-1]`. return su More
Balanced-R2R 1
Hi, I like this. Can you do it without `...if...else...`? Regards, suic More
First-inga.s 1
Hi, the built-in [__set__](https://docs.python.org/3.5/library/stdtypes.html?highlight=str.count#set-types-set-frozenset) object is better for this purpose than __list__. Look at [_set.intersection()_](https://docs.python.org/3.5/library/stdtypes.html?highlight=str.count#set.intersection). More
First-inga.s 1
Hi, when you have the following pattern: if condition: continue else: do_something is better to rewrite it like this: if not condition: do_something e. g.: if len(result) != 0: del result[0] Then have a look at [this](https://docs.python.org/3.5/l More
First-MrMike 1 1
```python # redundant # +-------------------------------------+ # | | # V V return max([(data.count(x), x) for x in set(data)])[1] # \--------------------------------------- More
max by key-shenghanteng 1 1
Hi, lambda is redundant as `data.count` is a function, so `return max(data,key=data.count)` is enough. Regards, suic More
return not any()-Alexona 1
Hi, 1. this `text.lower().find(l) == -1` is very un-pythonic. One of the most useful and powerful thing in Python is `in`: return not any(l not in text.lower() for l in letters) # or: return all(l in text.lower() for l in letters) 2. You could use `string.ascii_lowercase` instead More
First-ennisnie 1 1
Hi, `...if...else...` is redundant: ```python # bool # /-------------------\ return True if len(set(elements))<=1 else False # \--------------------------------------/ # bool return len(set(elements))<=1 ``` Regards, suic More
First-Moff 1
+5 for conciseness and for not using `fnmatch`. Regards, suic More
Fizz Buzz-illion 1 1
Hi, you don't need the `result` variable as well as the `number` variable. Line 19 is redundant. More
First-rdmar13 1 1
Hi, look at _str.isupper()_, _str.isupper()_ and _str.isdigit()_. More
simple sum-Alexona 1
Hi, _bin()_ returns a __str__, which has _str.count()_ method: return bin(number).count('1') # That's it :) More
First-anonymorf 1 1
Hi, this is not Pythonic for several reasons: 1. Line 2: `words` is a __set__, which is _iterable_ => no need to convert to __list__. 2. Line 4: `words` is _iterable_ therefore: def count_words(text, words): x = 0 for word in words)): if word in text.lower(): More
convert into regex-kurosawa4434 1
+5 for not using [fnmatch](https://github.com/python/cpython/blob/3.6/Lib/fnmatch.py) More
First-flex 1
Hi, I just would mention, that [] can be used instead of list() in this case: [... for ... in ... if ...] More
First-IrinaNizova 1
Hi, I have two comments: 1. You don't need to assign the value of enumerate (lines 2 and 6). You could write this: for i, _ in enumerate(matrix): ... for j, _ in enumerate(line): 2. But in fact using enumerate on lines 2 and 6 is inappropriate. This would be better: fo More
while loop-otonvm 1 1
Why loop? Look at _enumerate()_. More
First-Reloader 1
Hi, the same on one line: ```python def first_word(text): return text.replace('.', ' ').replace(',', ' ').strip().split()[0] ``` Regards, suic More
Mod (%)-quarkov 1 1
Hi, the use of `%` is nice but this solution is very inefficient as `str` is immutable and the following is an antipattern: ```python # this creates len(sequence) str objects s = '' for element in sequence: s += do_somthing_with(element) # creates a new str # these two are equivalent and way More
First-mihaillebedevdev 1
Hi that else branch is redundant. if ...: if lis is None and uis is None and dis is None and ais is None: return True # That return False is also redundant return False Look _any()_, _all()_ and _map()_. More