Answer to Question #136443 in Python for Kylee

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

Sample Run 1
Enter the Password: Ada Lovelace
Sample Output 1
Correct!
Sample Run 2
Enter the Password: Blaise Pascal
Sample Output 2
Not Correct
1
Expert's answer
2020-10-04T23:45:38-0400
#use a regular expression. 
import re #import regular expression. 
Password =input('Enter password:') #Request user input. 
Secret_phrase=r'Ada Lovelace'#define the regular expression. 
if re.match(Password,Secret_phrase):#use the re.match function to test if the user input matches the regular expression. 
  print('Correct!') 
else:
  print('Not Correct') 
    

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