I'm trying to make a login for a text-based OS in Python
I have tried to import time and time.sleep but it still doesn't work.
import time
usrname = str(input("What Is Your Username? "))
age = str(input("What Is You Age"))
print("Welcome",usrname)
if age <= 1:
print ("That`s An Invalid Age!")
time.sleep(3)
I don't see any errors because it's so fast it closes in 1/2 a second.
The condition
if age <= 1:is never going to be triggered, becauseageis a string. As a result, thetime.sleep()statement within theifblock is never going to run.In order for the conditional to work, you need to make
agean int (perhaps by doingif int(age) <= 1:).