I'm new to Python. I'm currently reading the book "How to Automate The Boring Stuff". I'm currently creating my first project. I'm creating a user login. I just got into the "def" define chapter. So I just implement it to my code. I can't figure out why my while loop won't break at "else". Sorry if my code looks very noobish. I'm a beginner and trying to learn from my mistakes.
P.S - This is my first post ever. Sorry if I'm not properly wording my question correctly.
edit - I've been creating this project for 3 days now.
import time
print("Welcome to my first User Login!")
time.sleep(1)
def creating_account():
print("First you will need to create a username!")
time.sleep(0.5)
asking_username = input("\nUsername: ")
time.sleep(0.5)
asking_password = input("Password: ")
time.sleep(1)
print("\nPerfect you have now created a User Login!")
time.sleep(1)
print("\nI will need your login information.")
login_username = asking_username
login_password = asking_password
userlogin_username = input("\nUsername: ")
userlogin_password = input("Password: ")
while True:
if userlogin_username != login_username or userlogin_password != login_password:
time.sleep(0.5)
print("\nSorry your username or password doesn't match with what We have on file. You may try again.\n")
userlogin_username = input("\nUsername: ")
userlogin_password = input("Password: ")
elif userlogin_username == login_username and userlogin_password == login_password:
break
print("\nProcessing..")
time.sleep(1.5)
print("\nYou have successfully login!")
asking_account = input("Do you have an account (y/n)? ").lower()
if asking_account == "n":
creating_account()
elif asking_account == "y":
print("Not possible, You must create an account.\n")
time.sleep(1)
creating_account()
else:
print("\nSorry, I don't understand. Make sure you're typing \"y\" or \"n\".\n")
time.sleep(0.5)
while True:
asking_account = input("Do you have an account (y/n)? ").lower()
if asking_account != "y" or "n":
print("\nSorry, I don't understand. Make sure you're typing \"y\" or \"n\".\n")
time.sleep(0.5)
elif asking_account == "y" or "n":
break
creating_account()