grandfathermagic

Bank2

Apr 21st, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. code = str(4812)
  2. attempt = 0
  3.  
  4. while attempt <= 3:
  5.     user_try = input("enter your code")
  6.     counter = 0
  7.     if "4" in user_try:
  8.         counter += 1
  9.     else:
  10.         counter
  11.     if "8" in user_try:
  12.         counter += 1
  13.     else:
  14.         counter
  15.     if "1" in user_try:
  16.         counter += 1
  17.     else:
  18.         counter
  19.     if "2" in user_try:
  20.         counter += 1
  21.     else:
  22.         counter
  23.     if user_try == code:
  24.         if user_try[0] == code[0] and user_try[1] == code[1] and user_try[2] == code[2] and user_try[3] == code[3]:
  25.             print("The safe is now open")
  26.             break
  27.     else:
  28.         print(f"you have {counter}  digits of the code ")
Add Comment
Please, Sign In to add comment