40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, line 5, 6 are almost the same. It's a good candidate for `lambda` or list comprehension.
More
Hi,
1. `lados` is redundant. `args` is a tuple => is iterable, so _list()_ is redundant.
2. you should decompose `args` like this:
a, b, c = args
3. You don't need _math.sqrt()_, there is the [_pow()_](https://docs.python.org/3.4/library/functions.html#pow) built-in function, and the `**` ope
More
Hi,
1. Line 6: [] are redundant.
2. Look at _filter()_
cnd = collections.Counter(filter(str.isalpha, text.lower()))
3. Line 7 that `for x sorted(): break` is so ugly. What's wrong with?:
return sorted([t[0] for t in most_common if t[1] == cnt_max], key=operator.itemgetter(0))[0]
More
Why not?:
def exclusive(x, y): return not(x == y)
def equivalence: return x == y
def implication: y if x else 1
More
Hi, this is two times the same code as you perform the same set of operation on _first_ and _second_.
A few suggestions:
1. You can use sorted(x) instead of x = list(x); x.sort():
x = sorted(x.lower())
2. You can avoid the redundancy mentioned above with a separate (or even nested) _
More
A _for_ loop would be a better solution for lines 5-10 e. g.:
for rep in (('IIII', 'IV'), ('VIV', 'IX')...):
large = large.replace(*rep)
__*__ before _rep_ unpacks the tuple.
More
There's a lot of redundancy:
1. You don't need to import string at all as you can use str.islower, str.isupper, str.isdigit.
2. Lines 8, 10, 12 contains the same pattern and also redundant checks:
# For example:
if sum([1 for c in data if c in string.ascii_lowercase]) == 0
More
Hi, I have two things:
1. Use str.join instead of resString + for loop (in this case ",".join())
2. list() is redundant on line 3 sorted() can consume sets.
More
Hi, two things:
1. list() is redundant as sorted can consume str.
2. lines 2 and 3 contains the same pattern, you could make it function or lambda function.
More
Hi, in fact the if is not necessary here as you can write:
any(len(word_group.split()) >= 3 for word_group in re.split(r"\d", words))
More
On line 9 you have three time the same pattern. You can use map/generator expression/list comprehension instead. E. g:
all(map(str.isalpha, wordlist[i:i+3]))
# or
all(i.isalpha for i in wordlist[i:i+3])
More
Hi, once you've found 3 word you can return immediately:
if count == 3: return True
More
Hi, don't use `sum` as variable name. You certainly know that it's a name of a useful built-in function. _sum()_ in action:
if not array: return 0
return sum(array[::2]) * array[-1]
More