Question: Write some code that repeatedly asks the user to enter a password until they enter the correct one. ( The correct password is python 1
Write some code that repeatedly asks the user to enter a password until they enter the correct one. The correct password is "python Count the number of incorrect attempts and display it once the correct password is entered.
Your code should perform the following steps:
Use a while loop to prompt the user to enter a password with the following prompt:
Enter the password:
If the user enters the wrong password, increase the count of invalid attempts by and prompt the user again.
The loop should stop only when the user enters the correct password, which is "python
Once the correct password is entered, display the total number of invalid attempts, using the following format:
Number of invalid attempts:
In the following sample run, the user enters the password incorrectly two times and then correctly the third time:
Enter the password: wrongpass
Enter the password: anotherwrongpass
Enter the password: python
Number of invalid attempts:
In the following sample run, the user enters the correct password the first time:
Enter the password: python
Number of invalid attempts:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
