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
sorted One Liner with lambda expression-pseudorandomcoder 1
Hi, `lambda` is redundant as `abs()` is taking one argument and functions are first class citizens in python: `return sorted(numbers_array, key=abs)`. Regards, suic More
First-hilokazu.yoshino
Hi, ```python text = text.split(' ') # This splits the string by spaces. text[0] = text[0].capitalize() # can be replaced with text[0].upper() text = (' ').join(text) # the first paren in redundant if text[-1] != '.': # not pythonic. There's the str.endswith More
First-MASIAIN
Hi, ```python if not text.endswith("."): text += "." ``` Regards, suic More
Clean and simple.-Celshade 1
Hi, interesting approach. The 0 on line three is redundant. Regards, suic More
First-daphnetingting
Let Python do the work for you: ```python from operator import itemgetter def bigger_price(limit, data): return sorted(data, key=itemgetter('price'), reverse=True)[:limit] ``` More
operator.itemgetter-jbwb 1
Hi, you could use `sorted()` instead of `list.sort`: ```python return sorted(data, key=itemgetter('price', 'name'), reverse=True)[:limit] ``` Regards, suic More
Second-tutumba 1
Hi, a bit shorter: ```python import time as t def time_converter(time): time = ('0' + time if len(time) < 10 else time).replace('.', '') return t.strftime("%H:%M", t.strptime(time,"%I:%M %p")) ``` Regards, suic More
breadth first search-1-more
Hi, very nice concise solution. When you need queue in Python, use [collections. deque](https://docs.python.org/3/library/collections.html?highlight=deque#collections.deque). `list.pop(0)` is very inefficient. ```python from collections import deque # ... queue = deque((r,c) for r,row in en More
Well, that's all . . .-Tinus_Trotyl 1
Can you do it without `...if...else...`? More
First-x2wing
In Python `super().__init__()` is enough. Also, you could make `is_alive` a property which prevents accidental assignments. Regards, suic More
Short, correct and absolutely rstripped-tovrey
Compared to other creative solutions, this one has at least a `lambda` :) More
range-Joni_Braslaver
As you actually don't use `item` except for decomposing it, you can do the decomposition directly in the for loop: ```python for first, last in items: # ... ``` Regards, suic More
First-freixodachamorra
This is an anti-pattern: ```python string = '' for i in self.connected: string += i.name + ' ' string = string[:-1] ``` You could write this instead: ```python string = " ".join(i.name for i in self.connected) ``` This is alternative for 85-89: ```python return {node.name for node in nodes More
First-denys.contant
Hi, `if all(digit in possible for digit in number):` is a shorter alternative for line 5. Regards, suic More
First-vovoka
Hi, I finally found a solution which doesn't use exceptions. However, this is quite inefficient: 1. `str_number = str_number[1:]` creates unnecessary intermediate strings. `for` loop is the preferred way to iterate over an iterable including `str`. 2. No 1. is actually needed because of `len(str_nu More
First-Matvey127
Hi, `str()` is redundant as `bin()` returns a `str`. Regards, suic More
7-liner-przemyslaw.daniel
Alternative: ```python def convert(n, d, f=__import__('itertools').product, r=range(1, 100), s=__import__('re').sub, q= __import__('decimal')): q.getcontext().prec = 100 k, p = str(q.Decimal(n)/d).replace('.', ''), str(n/d).find('.') for a, b in [(k[:x], k[x:][:y]) for x, y in f(r, r) if More
First-Tim4ek
Hi, lines 2 and 3 are redundant. More
Break Down-Lingson
I agree with the previous comment. This is "refactorable" to one function without nested functions in one minute. More
First-edomaur
Nice, short and clear. Consider to move it to Clear section. More