mardi 19 octobre 2021

Create a python file that asks user 4 digit pin

I have an assignment where I have to ask the user for a 4 digit pin. The correct pin is 1234. I have to give the user 3 times before they're locked out. I also have to add a break statement. This is the example of the output:

Please enter your pin code: 1112

Incorrect. Please enter again: 1112

Incorrect. Please enter again: 1234

Correct.

My code:

def verify_pin(pin)
if pin == "1234"
   return True
else:
   return False

tries = 3
while counter < 3:
  pin = input("please enter your pin code")
  if verify_pin(pin)     
  print("Correct")
  break
elif 
   print("Incorrect.Please enter again: ")
tries +=1  

I received an invalid syntax. I don't know what I am doing at all but I really want to understand and learn. Please help.

Aucun commentaire:

Enregistrer un commentaire