40
suic
16 39 57
9966/ 10664
Last seen 1 day ago
Member for 9 years, 11 months, 4 days
Difficulty Advanced
Best reviews / Newest reviews
First-StaticFuzz
Hi, this try: int(xy) except ValueError: ... is quite ugly and in fact you don't have to do that as there is the _str.isalpha()_ method: if string.isalpha(): word_seq += 1 else: word_seq = 0 More
First-StaticFuzz
Hi, you don't need re.sub. __str__ has _str.replace()_ method. You can also omit the new_string variable: return ','.join(phrases).replace('right', 'left') More
First-StaticFuzz
Hi, you don't need the message variable and you can omit []. You can also use str.uppercase instead of importing string.ascii_uppercase: return ''.join(char for char in text if char.isupper()) # or you can use filter: return ''.join(filter(str.isupper, text)) More
Goulib.math2.get_cardinal_name-Goulu
Hi, why not: filter(None, iterable) # instead of: filter(bool, iterable) ? More
One liner-Goulu
Hi, you can use _str.isupper_ instead of lambda c: c.isupper(). More
First-CraigFranklin 1
Hi, let me have some comments: You don't need: 1. the else branches at all. 2. "== True" as test is a bool. 3. the test variable as you can use any as a condition. 4. letts as you can use data instead. 5. the parentheses on lines 5-7. After this basic cleanup your code looks like this: def c More
The hard way.-CraigFranklin 1 1
Hi, this is "overparenthesized" :D # E. g.: bin_n = bin(n)[2::][::-1] bin_m = bin(m)[2::][::-1] + diff_len * "0" More
First-CraigFranklin 1
Hi, look at documentation for _sorted()_. Sorted has _key_ argument, which is quite useful. More
First-CraigFranklin 1
Hi, parentheses around bin(number) are redundant. More
First-CraigFranklin 1
Hi, you don't need _alph_: for i in string.ascii_lowercase: ... More
LambdaWay-VickZVD 1
Hi, lambda here is completely unnecessary (or it has obfuscation purposes?). return [x for x in data if data.count(x)>1] More
De Morgan's law FTW-VickZVD 1
Hi, you can replace the chain of ors with any(): checkio = lambda p: len(p) > 9 and not any((p.isalpha(), p.isupper(), p.islower(), p.isdigit())) # or: checkio = lambda p: len(p) > 9 and not any(f(p) for f in (str.isalpha, str.isupper, str.islower, str.isdigit)) More
First-msboom
Hi, 1. [] are redundant. 2. ... if ... else ... is also redundant: return sum(w in text.lower() for w in words) More
First-msboom
Hi, # instead of [int(i) for i in str(number)] # you can write: map(int, str(number)) More
lambda, 1 line-AmaroVita 1
Hi, in "".join() the [] are redundant. More
First-AmaroVita
Hi, you have three times the same pattern chained with and => you can use all() and generator expression instead. More
First-AmaroVita 1
Hi, you could write r+=['Buzz'] or better r.append('Buzz'). More
First-AmaroVita 1
Hi, parentheses around ",".join(phrases) are redundant. More
First-pytonio
Hi, you could use generator expression instead of _map_. More
First-pytonio 1
Hi, have a look at [this](https://docs.python.org/3.4/library/stdtypes.html#truth-value-testing). # You can omit the ... if ... else ...: return bool(re.search('\D+( \D+){2,}', words)) Last but not least with \_\_import\_\_() and lambda you could transform it to a nice one-liner :) More