Answer to Question #253852 in Python for adrian

Question #253852

Test if a password entered is correct. The secret phrase is Ada Lovelace.



1
Expert's answer
2021-10-20T00:07:13-0400
#A program to test if a password entered is correct
#We will use a while loop so that a user can try entering the password as many time
#as he/she wants
terminate_condition = 1
while terminate_condition == 1:
    #Prompt the user to enter a password
    password = input("Enter a password: ")
    #Check if the password entered is correct(the correct/secret password is "Ada Lovelace"
    if password == "Ada Lovelace":
        print("The password you have entered is correct")
        #Now update the terminate condition to make the loop execute no more
        terminate_condition = 0;
    else:
        print("Incorrect password, please try again")
        print("To try again enter 1 otherwise any other number")
        option = int(input("Enter the your option: "))
        #update the terminate condition
        terminate_condition =option
        if option!=1:
            print("Program exited ")

SAMPLE PROGRAM OUTPUTS



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS