12
Aleksey Konotop
Last seen 2 months ago
Member for 5 years, 8 months, 14 days
Difficulty Normal
Why do you do a check like this:
if letter.isupper() == True:
It's wrong.
if letter.isupper():
It's correct.
Good luck.
More
Good. But could you explain why the minus sign is in front of the variable x? Thanks a lot.
More
A good solution, but is it necessary to check for other characters, because other characters can not be capitalized. Only letters can.
More
You just need to check the array without specifying the number of elements in it.
You can write like this:
def checkio(array):
return sum(array[::2]) * array[-1] if array else 0
# Another way to solve
# return len(array) and sum(array[::2] * array[-1])
Why that?
B
More
Why did you write like this?
...
elif n == 0:
return 1
...
When raising to the power of 0, the result is 1.
More
Yes, this solution is more difficult to understand, but if you think about it, everything becomes obvious.
More
This solution works, but you can do everything in one line and do not create unnecessary variables.
Like this:
def checkio(*args):
return abs(min(args) - max(args)) if args else 0
What you think about this solution?
More