+ 1
Python loops
Please can some help me with this Iâve been stuck on this Create a timer program that will take the number of seconds as input, and countdown to 0. My code: #⢠take⢠the number as ⢠input number = int (input ()) #use a while loop for the countdown number= ⢠while number >0: ⢠â˘print(⢠number-1) ⢠⢠number= number-1 I know there is a problem with my 4th row of code but I donât know what it is. Itâs supposed to work of any input variable because itâs those practice questions. Please đđž
2 Answers
+ 4
Use tab to keep equal whitespace
+ 4
Sanelisiwe Ndlovu, you have an extra whitespace
When indenting, try to follow the block correctly
num = int(input())
while num >= 0: # creating a block of the while loop.
while num >= 0:
print(num)
num = num -1
keep your indentations correct. If you indent 4 whitespaces to begin with, then your next indentation is the same 4 whitespaces.
https://sololearn.com/compiler-playground/cWthExZYN602/?ref=app