import sys
import string
import time
password = "1234"
guess = " "
count = 0
def bank():
print("TKS Bank")
print("Enter your pin below to access your TKS Bank account")
print()
def password():
global password
global guess
global count
while count != 3 and guess != password:
guess = input("Please enter your 4 digit pin: ")
count += 1
if guess == password:
menu()
elif count == 3:
print("Number of tries maxed.")
countdown()
count = 0
else:
print("Your pin is denied, Try again")
def menu():
print("Your pin has been approved")
print("_" * 80)
print("Welcome to the TKS Bank")
print("_" * 80)
print("1. Type 1 to check your account balance")
print("2. Type 2 to to deposit a chosen amount")
print("3. Type 3 to withdraw a chosen amount")
print("4. Type 4 to check your simple interest")
print("5. Type 5 to exit the menu")
print("_" * 80)
def balance():
balance = (random.randint(1,1000))
print("$", balance)
#'sys' imports the system library from the python library
def quit():
os.exit(0)
def countdown():
print("You have been locked out for 3 minutes. Please come back later
and try again")
time.sleep(3)
bank()
password()
当我有倒计时功能时,密码不起作用,只是不断循环。有人有修复吗?
要在我输入正确的密码时使用倒计时功能进行扩展,它会说它不正确并在三次尝试后进入倒计时。我真的不知道解决方案是什么,所以任何人的帮助都会受到赞赏。
答案 0 :(得分:0)
在def password():
函数中,变量password
和函数password
之间的名称使用不明确。