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
"short" comprehension list -val0u
Hi, `range(0, x) == range(x)`. More
Using any!-Anas_Alzahrani
Hi, 1. All `== True` checks are redundant. 2. All `else` branches are redundant. 3. Finally: When you use _any()_ with `and` or _all()_ all the `if`s are redundant. Your code after step 2.: def checkio(data): if len(data) >= 10 : if any(c.islower() for c in data): if More
First-Rosetta93 1
Hi, `len` is redundant: if len(data): ... else: ... More
Difference-Seter 1
What about: def checkio(*args): if not args: return 0 return max(args) - min(args) More
First-Hayertjez
Hi, that `else` branch is redundant. This is enough: ~~~~ def verify_anagrams(first_word, second_word): first = first_word.replace(" ", "").lower() second = second_word.replace(" ", "").lower() for x in first: if first.count(x) != second.count(x): return False More
Terrible ?-Seter
A bit :) 1. Intstead of lines 7-9: `return "".join(result) == 'abcd...z'` 2. Look at [_sorted()_](https://docs.python.org/3/library/functions.html?highlight=sorted#sorted). It takes any iterable including __set__. Refactored: ~~~~ import re from string import ascii_lowercase def check_pangram(t More
First-pmb311 1
Hi, this is inefficient. It builds list just for checking its length. This is much better: sum(date(year, i, 13).weekday() == 4 for i in range(1, 13)) More
One Line-thierry.kleinhentz
Hi, look at [_extended slices_](https://docs.python.org/3/whatsnew/2.3.html?highlight=extended%20slices#extended-slices). More
HELLO-laetrid
Hi, this is inefficient because __str__ is immutable i. e. each `result += char` creates a new string. You could use: 1. [_filter()_](https://docs.python.org/3/library/functions.html?highlight=filter#filter) or [_generator expression_](https://docs.python.org/3/whatsnew/2.4.html?highlight=generator More
First-Jason721
Hi, 1. _list()_ is redundant. [_filter()_](https://docs.python.org/3/library/functions.html?highlight=filter#filter) returns an _iterable_ which [_str.join()_](https://docs.python.org/3/library/stdtypes.html?highlight=join#str.join) can consume. 2. __str__ has [_str.isupper()_](https://docs.python More
Not efficient but short -LPK
Hi, 1. `[]` are redundant. 2. __bool__ is subtype of __int__ so you could write: text = text.lower() return sum(x in text for x in words) \---+---/ | bool More
First-Kiseloff
Hi, you could write: return ... if args ... else ... More
First-topazo
Hi, have a look at [__Counter__](https://docs.python.org/3.5/library/collections.html?highlight=counter#counter-objects). More
One-line solution-eredinbg
Hi, you don't need math.pow. There's a power operator in python: **. More
Index Power-thinkdefacto
Hi, `a` is redundant. You could write: `return array[n] ** n`. More
First-jackhead
Hi, I've made a few changes: def checkio(first, second): longer = max((first, second), key=len) shorter = min((first, second), key=len) common = (word for word, word2 in zip(shorter.split(","), longer.split(", More
First-srinish.rawoor
Hi, there's is quite a lot of redundancy in this solution: return len(data)>=10 and all(re.search(pat, data) for pat in ('[0-9]+' ,'[A-Z]+', '[a-z]+')): and also an anti-pattern: if cond: return True else: return False # is the same as return bool(cond) More
One line regex-SimonTC
Nice _perlish_ line noise! Good job! More
Clear -Vesemir
Hi, nice solution, but why don't you returned the condition? return len(data) >= 10 and contains_digits(data) and contains_upper(data) and contains_lower(data) \-----------------------------------------------------------------------------------------/ More
even the last-weroniquue 1
Hi, I this case you let Python to do the work fork you: ```python ostatni = array[-1] suma = sum(lista)` # or even suma = sum(array[::2]) ``` You don't need the `else` branch. Regards, suic P. S.: Jest to jakas praca domowa? More