Basically I'm creating a program which allows users to create a password and username. If they done it right then the program will ask them to log in. If the password and username they enter are right it will stop and say welcome. The problem is the password and username is always invalid even when its right so it keeps looping.
import time
def username():
total=0
while total != 600:
time.sleep(1)
username=input("Create a username(must be 6 chatacters long):")
if len(username)== 6:
break
else:
time.sleep(1)
print("Your username is invalid")
print("Try again")
total=total+1
def password():
totalP=0
while totalP != 6:
time.sleep(1)
print("the password must be 5-8 characters long")
print("Contains atlease 1 capital letter")
password=input("please enter your password:")
password2=input("please enter your password again")
if len(password)>5 and len(password)<8:
if password.title() == password:
if password.title()==password2:
break
else:
print("Your password is invalid, please try again")
totalP=totalP+1
option=input("Do you want to create an account(Y/N)")
if option.title()=="Y":
username()
password()
else:
pass
print("Hello please log in")
total3=0
while total3 < 12:
log1=input("what is your username?")
log2=input("what is your password?")
if log1 != username:
print("your username is invaild, please try again")
total3=total3+1
if log2 != password:
print("your password is invaild, please try again")
total3=total3+1
else:
break
if total3 < 12:
print("you must wait 2 days before you could enter your username again")
else:
print("hello, wellcome to my program")
Aucun commentaire:
Enregistrer un commentaire