You only have three attempts.

A four digit personal identification number (PIN) is required to access a system. If the user enters the PIN correctly they can continue. If the user enters the PIN incorrectly they are prompted for their PIN again. There are a maximum of three attempts, after which the user is locked out for security.

PIN

⭐⭐⭐

Make

Write a program that asks the user to enter their PIN. If they enter the incorrect PIN three times, the program outputs, “Locked out.” If they correctly enter 7528 the program outputs, “Security check passed.”

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Create a subprogram called get_pin that:

  1. Asks the user to enter their PIN.
  2. The input is compared against the valid PIN 7528.
  3. If the input is incorrect the user is prompted for the PIN again a maximum of three times.
  4. The function returns True if the PIN is valid.
  5. The function returns False if the PIN is invalid.

Complete the main program so that:

  1. The subprogram get_pin is called.
  2. The message, “Security check passed” is output if the validation is passed.
  3. The message “Locked out.” is output if the user fails to enter the correct PIN after three attempts.

Typical inputs and outputs from the program would be:

Enter PIN: 2311
Enter PIN: 2213
Enter PIN: 7895
Locked out.
Enter PIN: 6753
Enter PIN: 9622
Enter PIN: 7528
Security check passed.
Enter PIN: 7528
Security check passed.