Skip to content

Crack the Code

  • Project
  • 1 hint
  • 5 of 5 in this chapter

Assignment

For this mini project, let’s create a PIN based security system. For this program, the program should allow the user to input 3 tries for a PIN.

If the user is correct on either of those tries, the user should be shown a success message, if not, the user should be shown a message saying that access is denied.

  • Have a while loop running until the user has done 3 tries or has got the PIN right
  • Then, the user should get a message depending on whether they were successful or failed to log in.

Hints

Hint 1Hint 1

a

Solution

Python
attempts = 0
correct_pin = '1056'

while attempts < 3:
    pin = input("Enter PIN:")

    if pin == correct_pin:
        print("You have successfully logged in!")
        break

    else: 
        print("Incorrect! Try again…")
        attempts += 1

if pin != correct_pin:
    print("Oops. Seems like you’ve forgotten your PIN. Reset ur PIN to continue...")

Give the project a try first.