I am trying to write a simple block of python code that I would like to reuse in future programs. It will check to see if a password is correct and if it is not return to the first line of code and start the process again. The way I am attempting to accomplish that gives me an error. Can anyone help me find a better solution?? Here is the code I am currently using:
def password_checker():
program_acceptance = "Welcome to the Program! "
acceptable_password = "Godisgood"
print("Please Enter the Password")
while True:
password = input("Password: ")
if password == acceptable_password:
print(program_acceptance)
break
if password != acceptable_password:
print("Invalid password, please try again..."
break