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
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
First-Bidonus
Hi, all the `if`s are redundant: ~~~~ # as: if cond: return True else: return False # is the same as: bool(cond) # when the condition is itself a bool than bool() is redundant # and: if cond_a: if cond_b: ... # is the same as: if cond_a and cond_b: ... # ------------ More
Probably not the best solution, but I did it all by myself (beginner)-gary.d.russell
Hi, you could write: 1. `return not len(alphabet) > 0` instead of lines 7-10 2. `alphabet = list(string.ascii_lowercase)` 3. `text = text.lower()` More
First-frantisek.jahoda
Hi, what about [__deque__](https://docs.python.org/3.5/library/collections.html#collections.deque)? More
Reduce-frantisek.jahoda
Hi, you could you `ge` and `le` from the `operator` module. from operator import ge, le def max(*args, key=lambda x: x, cmp=ge): ... def min(*args, key=lambda x: x, cmp=le): ... 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
absolute-weroniquue
Hi, `sorted()` doesn't modify the `number_array` variable => you can omit `x`. More
binarne-weroniquue
Hi, nice math-based solution. :) few Python tweaks: 1. `divmod()` is an excellent built-in function. 2. __`str`__ has `str.count()` method, which can do the work for you: `bin(number).count('1')` as `bin()` returns a __`str`__. Regards, suic ```python # divmod def checkio(number): wynik = 0 More
First-jantechner
Hi, this isn't very Pythonic :( I'm wondering how it got 57 upvotes. ```python from math import acos, degrees ​ def is_correct_triangle(a,b,c): return a+b>c and a+c>b and c+b>a def angle(a,b,c): d = (a**2 + b**2 - c**2)/(2*a*b) return round(degrees(acos(d))) def checkio More
First-YellowTree
Hi, `pass` in `if..else` usually indicates redundant branch like in this case: ```python def checkio(number): result = 1 for ch in str(number): i = int(ch) if i != 0: result *= i return result ``` More
First-Domenica_Coello
Hi, you can omit the `[]`. Regards, suic More
BFS-DaveDiFranco
Hi, Using `list` as a queue isn't optimal. `collections.deque` would be a better option here as `p = q.pop(0)` is `O(n)` while `q.popleft()` is `O(1)`. (see a nice summary [here](https://wiki.python.org/moin/TimeComplexity)) Regards, suic More
First-cshea
Hi, `lambda` is redundant: ```python return filter(str.isupper, text) ``` Regards, suic More
Second-cshea
Hi, `list` and `lambda` are redundant: ```python return ''.join(filter(str.isupper, text)) # 1. filter expects a function as its first argument and str.isupper is a function. # 2. `str.join` accepts any iterable including filter object. ``` Regards, suic More
First-Heerk
Hi, this solution isn't quite Pythonic. Regards, suic ```python import re#(dundant) ​ def find_message(text): for ch in filter(str.isupper, text): message = message + ch # inefficient as str is immutable # (on the other hand doesn't matter for small inpu More