I have this number guesser code, and everything works, but I would like to make a command that will print 'you were too slow' if you take more than 20 seconds.
This is the code:
import random
def guessr():
choice = int(input("Guess the number the Game(TM)\nType 1 to play\nType 2 to have the computer play."))
if choice == 1:
guess = int(input("Your guess? "))
Rnumber = random.randint(0,100)
while guess != Rnumber:
if guess < Rnumber:
print("Your number is too low.")
elif guess > Rnumber:
print("Your number is too high.")
guess = int(input("Your guess? "))
print("Good job! The number was",Rnumber,":)")
elif choice == 2:
Rnumber = random.randint(0,100)
guess = 0
while guess != Rnumber:
print('It is not',guess)
guess = random.randint(0,100)
print('The number is',Rnumber)
guessr()