I’m a novice and I have been trying to build a random countdown timer which picks a number between 0 and 10, and counts to zero from the selected integer. All while printing the countdown simultaneously. However, I keep getting errors from sleep().
import random
import time
x = random.randint(0,10)
y = time.sleep(x)
while y != 0:
print(y)
This might be help you:
import random
import time
countdown = random.randint(0,10)
for i in reversed(range(countdown)):
print(str(i) + ' sec left')
time.sleep(1)