0
Please guys... Help me with this code on while loop ... Input is 3 and 5, should countdown to zero... Bt still failed response
# take the number as input number = int(input()) #use a while loop for the countdown Timer = 5 while Timer > -1 : print(Timer) Timer = Timer - 1
2 ответов
+ 5
If I understand your question right, you want to make counter to count to 0 from the given number. If that is the case then you should use 'number' variable instead of 'Timer' like this
number = int(input())
while number >= 0:
print(number)
number -= 1
+ 3
CHRISTIAN ,
Dejan Francuz🥇 already gave the answer, but I want to give you a tip about naming new variables. They should be lower case, like timer, not Timer. Later, when we start naming classes, we use capitalized nouns, like Timer. Conventions make it easier for everyone when reading each others' code.
Search "Python PEP 8" for more info about naming conventions and formatting conventions.