I am very very new to python and I am trying to make a simple timer app with it.
So if I input a number, like 30, the code should start counting down and output
>>> 30
>>> 29
>>> 28
>>> 27
and so on..
I am trying to get some logic into my brain. I was trying to do this since to days with same code in different places.
import time
x = input("seconds to blast off: ")
for z in range(x):
timer.sleep(x)
print("blast off")
This is all I have written and I am stuck here.
>Solution :
Try this:
import time
sec = int(input('No. of seconds: '))
print(sec)
for s in range(sec):
sec = int(sec) - 1
time.sleep(1)
if sec == 0:
print("Blast Off")
else:
print(str(sec))
You got quite close to the solution.
timer.sleep() takes in the number of seconds.
Although, you could have found such answers on the web.