40
Last seen 1 day ago
Member for 9 years, 11 months, 4 days
Difficulty Advanced
Hi, I'm just curious: Do you come from .NET world?
I have also some comments:
1. It's not a big thing but don't use variable names beginning with underscore.
2. bool() is redundant in all four cases. check1 is completely redundant as len(data) >= 10 is already a boolean.
3. You can replace nested
More
Hi, I have a few comments
1. all the parentheses around _operation == ..._ are redundant.
2. As _True == 1_ and _False == 0_ you don't the nested ifs. E. g.
...
elif operation == "equivalence":
return x == y
...
3. The last line is useless.
4. On lines 5, 9: Use _and_ instead o
More
Hi, I have some comments:
1. Line 14 is unnecessary.
2. __str__ is iterable, so you can directly iterate over it without an integer index.
3. The if...else is redundant. y * 1 == y so it does not make sense to perform that operation.
4. You can write y *= int(a[i]) instead of y = y * int(a[i])
5. A
More
Hi, I have two comments:
1. If...elif...else if redundant.
2. else brahch in for is also redundant.
This is enough:
def checkio(words_set):
for word in words_set:
for suf in words_set:
if (suf != word) and (word.endswith(suf)):
retur
More
Hi, why not?:
return any(word1.endswith(word2) for word1, word2 in permutations(words_set, 2))
More
Hi, you can do it without _math.pow()_. There's a power operator: __**__ (see [this](https://docs.python.org/3/library/stdtypes.html?highlight=binary%20operator#numeric-types-int-float-complex)).
More
Hi, I have a comment:
Lines 5 and 8 are the same, so you can write it this way:
if int(time_lst[0]) > 12:
time_lst[0] = int(time_lst[0]) - 12
else:
time_lst[0] = int(time_lst[0])
time_lst[1] = int(time_lst[1])
# or even:
time_lst[0] = int(time_list[0]) -
More
Hi,
1. The last if...else is redundant.
2. _ad_ line 3: __set__ has _set.add()_ method.
3. Lines 4, 5 are redundant because all you should replace is space, as there is the precondition:
> Words contain only ASCII latin letters and whitespaces.
Your code after cleanup:
def verify_anag
More
Hi,
1. Use consistent indentation.
2. Return prod > 0 is enough, you don't if...else.
3. Using multiplication is an interesting approach, but redundant. Once you find _count_ == 0 the result is false.
4. You can import string.ascii_lowercase instead of chars.
from string import ascii_lowercas
More
Hi,
1. i>= is already a bool so if...else is redundant:
return i >= 1 # or even return i > 0
2. Once you've found a pair, it does not make sense to continue. So you can move the return inside the if and omit the _i_ variable:
for every in words_set:
if every.endswith(tuple(word
More
Hi,
1. What is the point of allcaps variable names? (In fact you don't need any of these variables.)
2. _ad_ lines 6, 7: Look at _str.join()_.
3. Look at slices in python:
return s[1:] # is enough.
More
Hi, you don't need the data variable as you can return it directly:
return [i for i in data if data.count(i) != 1]
Tip: Feel free to remove the comments :)
More
Hi, with any, you can write lines 3-6 like this:
return len(lst) >= 3 and any(''.join(lst[i:i+3]).isalpha() for i in range(len(lst)-2))
More
Hi, I have some comments:
1. You can replace all the _elif_ with _if_ and remove the _else_.
2. != True and == True checks are redundant:
# E. g.:
# data.isalnum() is already a bool so:
if not data.isalnum(): return False
# same for data.isdigit():
if data.isdigit(): retur
More
Hi,
1. test if string is not a digit/number with try...except, why?
# There are methods like
# str.isnumeric() or str.isalpha() for that.
2. for each?
for w in splitted_words:
if w.isalpha():
tf_string += 'True'
else:
tf_string += 'False'
More
Hi,
1. Look at negative indices: A[len(A)-1] == A[-1].
2. You don't need to sort A when it's empty.
3. Instead of:
if A == []:
...
# you can write:
if not A:
...
More
Hi, a few comments:
1. You don't the for loop and _Capitals_ variable:
return "".join(ListOfCapitals) # str.join() in action
2. You don't need re:
# verbose :)
res = []
for letter in text:
if letter.isupper():
res.append(letter)
return "".join(res)
More