Test if a password entered is correct. The secret phrase is Ada Lovelace.
#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
Comments
Leave a comment