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
Boolean Algebra-lukas.linhart 1
Hi, look at [this](https://docs.python.org/3/library/stdtypes.html?highlight=str.isupper#truth-value-testing). You can omit the majority of ifs: 1. Lines 5-6: return x and y 2. Lines 8-9: return x or y 3. Lines 14-15: return x != y 4. Lines 11-12: not(x and not y) 5. Lines 17-18: return x == y More
Right to Left-lukas.linhart 1 1
Hi, I have a few comments: 1. You don't need _re_ as __str__ has _str.replace()_ method. 2. When you join first and then replace, you can replace all at once: return ",".join(phrases).replace("right", "left") More
First-MASIAIN 1
Hi, 1. Don't comment obvious things. It's not useful. 2. All that "magic" with `Counter.most_common` is redundant. Regards, suic ```python from collections import Counter def checkio(lis): c = Counter(lis) return [e for e in lis if c[e] > 1] ``` More
Boolean Algebra-inga.s 1
Hi, __bool__ is a subtype of __int__, therefore the nested `if`s are redundant, e. g.: elif operation == "equivalence": return x == y elif operation == "exclusive": return x != y More
First-polly 1 1
Hi, you can omit the [] braces. More
First-mfurones 1
It's not a bad solution, but it can be improved: 1. [Set](https://docs.python.org/3/library/stdtypes.html?highlight=intersection#set-types-set-frozenset) is more suitable for this task. 2. You could replace this: c = [] for i in a: for j in b: if i==j: c.append(i More
Correct Sentence-ouhuazheng 1 1
Hi, 1. `str.capitalize` makes sense if you apply it on string longer than one character. `str.upper` is enough here. 2. Instead of `if text[-1]!='.':` you can use `text.endswith('.')` 3. You can shorten the last three lines like this: ```python return text + "." * (not text.endswith('.')) ``` R More
Regex?-mscmorris 1 1
Hi, you could write it also this way: return bool(re.compile('.*?[a-zA-Z]+ [a-zA-Z]+ [a-zA-Z]+.*?').match(words)) # :) More
wrapping up the idea-PyPoet 1 1
Hi, `[]` are redundant. Look at _filter()_. More
comprehend comprehension-PyPoet 1 1
Even more elegant solution: return sum(word in text.lower() for word in words) # :) More
lambda, 1 line-AmaroVita 1
Hi, in "".join() the [] are redundant. More
should have known about slicing arrays earlier...-PyPoet 1 1
Hi, 1. This is rather "selfobfuscating" than clear. 2. Look at _extended slices_. Both `indexlist` and `valuelist` are redundant: valuelist == array[::2] 3. `if not array:` better than `if len(array) == 0:` More
Normally Solved-Golli19 1
Hi, 1. Line 14 is never reached. 2. Look at _list comprehensions_. More
First-AmaroVita 1
Hi, you could write r+=['Buzz'] or better r.append('Buzz'). More
Normally Solved-Golli19 1
Hi, this is way to complicated and completely misses the beauty and simplicity of Python: 1. Line 2: `numbers_array` is a __tuple__ which is iterable => _list()_ is redundant. 2. Lines 3, 4: Look at _extended slices_. 3. Lines 6-8: You don't need `tmp` variable as you can swap `j` and `j+1` like th More
Normally Solved-Golli19 1
Hi, 1. There's the _abs()_ built-in function: `return abs(d.days)` 2. You can unpack variables with `*` e. g.: d = date(*date1) More
Normally Solved-Golli19 1
Hi, look at _filter()_ and _str.join()_. More
First-AmaroVita 1
Hi, parentheses around ",".join(phrases) are redundant. More
Normally Solved-Golli19 1
Hi, look at _any()_ and _generator expressions_: return any(i != j and (i.endswith(j) or j.endswith(i)) for i in words_set for j in words_set) # That's it :) More
Normally Solved-Golli19 1 1
Hi, this is not Pythonic: 1. `phrases` is a __tuple__ which is iterable, therefore you can write: for i in phrases: ret += i.replace("right", left") ... 2. __str__ has _str.join()_ method, which does the same as your for loop: ret = "".join(i.replace("right", "left") for More