40
Awesome Team
Alexander Lyabah
http://www.checkio.org/user/oduvan/
Last seen 14 hours ago
Member for 13 years, 10 months, 21 days
Difficulty Easy
love it!
I feel like Python should have something built-in for compose function. I'll try to find. :)
More
i = 0
j = 2
while j <= len(a):
pair = a[i:j]
list_with_pairs.append(pair)
i += 2
j+=2
this piece of code repeats twice. Can it be avoided?
More
line 6: `if items == []:` it is better to do it like this `if not items:`
line 9: you can say `if` instead of `elif`, why?
More
you don't need variable new_string. How to solve this problem without this
variable?
More
I've just found out that definition of `str.count` is different than `list.count`
>>> help(list.count)
count(...)
L.count(value) -> integer -- return number of occurrences of value
>>> help(str.count)
count(...)
S.count(sub[, start[, end]]) -> int
More
http://www.python.org/dev/peps/pep-0008/#function-names
> Function names should be lowercase, with words separated by underscores as necessary to improve readability.
More
Thank you @veky, this is something new for me today
https://docs.python.org/3/library/contextlib.html#contextlib.suppress
More
`str.split(' ')` will work the same as `str.split()` for current mission. For which cases it will work differently?
also, if you need `i` just for getting element from list by index `sep[i]`, then you probably don't need i and you can simply do:
`for word in sep:`
isn't cool? :)
More
good solution, and very good direction of thinking.
couple notes here. If you want to check - if list is empty or not, you can simply do:
if not list_to_check:
# list is empty
return False
also this code
if (len(set1) == 1):
return True
else:
return F
More
немного можно преобразовать.
Во-первых можно сделать так, что если длинна меньше указанной, то просто вернуть False, тогда будет меньше отступов:
def checkio(data: str) -> bool:
if len(data) < 10:
return False
if data.isdigit():
return False
More
too many tabs. Same solution but without that many tabs:
def end_zeros(num: int) -> int:
if num == 0:
return 1
if num < 9:
return 0
x = num
y = 0
while x > 9 and x % 10 == 0:
y += 1
x
More
I think I saw something like this already, but instead of your like 6 it was replace expression.
More
line2: if you change -1 to 1 it will work anyway. Do you know why?
More