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-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
Second-colinmcnicholl 1 1
Hi, here's a bit shorter alternative: ```python import string def checkio(str_number, radix): d = dict(zip(string.digits + string.ascii_uppercase, range(36))) decimals = [d[num] for num in str_number] if radix <= max(decimals): return -1 return sum(dec * radix ** (l 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
Bitwise XOR and string manipulation-paren8esis 1 1
Hi, `bin()` returns a __`str`__ so `str()` is redundant. More
One line method-titaneric 1 1
Hi, this can be made more compact with `filter`: return "".join(filter(str.isupper, text)) Regards, suic More
Itertools with Permutations-arma 1 1
Hi, you can shorten it using _any()_: return any(a.endswith(b) for a, b in permutations(words_set, 2)) More
isupper-Peter.White 1 1
Hi, consider the fact, that __str__ is immutable in Python. And look at _filter()_ function or _list comprehensions_/_generator expressions_. # E. g.: return "".join(filter(str.isupper, text)) # That's it :) More
First-dedked 1 1
Hi, [] are redundant. Tip: Look at _filter()_. More
Readable way with IndexError catch-arma 1 1
Hi, why try...except? You can easily handle it by _if_ or _and_. E. g.: if array: ... else: return 0 More
One line method-titaneric 1 1
Hi, look at [extended slices](https://docs.python.org/2/whatsnew/2.3.html#extended-slices): ```python array[::2] # is the same as [num for i, num in enumerate(array) if i % 2 == 0] ``` Regards, suic More
First-CraigFranklin 1
Hi, parentheses around bin(number) are redundant. More
Exp: sets & combinations-druifor 1 1
Hi, using Pythonic way of iterating over an iterable `for element in seq:` in combination with `itertool` can make your code more compact and readable (see the example below). Regards, suic ```python from itertools import combinations, chain def build_sides(my_sides, dif): forl = [sorted(c More
First-CraigFranklin 1
Hi, look at documentation for _sorted()_. Sorted has _key_ argument, which is quite useful. More
First-Rita 1
Hi, `bool` is a subclass of `int`, therefore the nested `if`s are redundant. More
First-davidezal 1
This is so funny :) 1. "all the magic" (including `itertools.groupby`) on one-line. 2. wrapped by a typical newbie `if...else...` anti-pattern. ```python return ( subj.isupper() # bool or subj.endswith('!!!') # bool or any(...) # bool ) 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-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