You have a misunderstanding of something. n is a number. str(n) turns it into a string. strip just removes the leading and trailing characters. All of this 'launches' in both cases. The int throws an error if it receives an empty string, which is the case if input is only zeros, since you strip them.
It doesn't skip anything. Python's or statement returns the left side if it is true and with strings that is whenever the string is not empty. Only when the left side is false does it proceed to evaluate the right side and it returns it regardless of is it true or false.
Now I get it. Thank you!
You have a misunderstanding of something.
n
is a number.str(n)
turns it into a string.strip
just removes the leading and trailing characters. All of this 'launches' in both cases. Theint
throws an error if it receives an empty string, which is the case if input is only zeros, since you strip them.This comment is hidden because it contains spoiler information about the solution
It doesn't skip anything. Python's
or
statement returns the left side if it is true and with strings that is whenever the string is not empty. Only when the left side is false does it proceed to evaluate the right side and it returns it regardless of is it true or false.This comment is hidden because it contains spoiler information about the solution