Python 3.x 为什么我输入密码时密码不起作用?

Python 3.x 为什么我输入密码时密码不起作用?,python-3.x,Python 3.x,当我有倒计时功能的密码不工作,只是不断循环。有人有办法吗 为了扩展倒计时功能,当我输入正确的密码时,它会说密码不正确,并在三次尝试后进入倒计时。我真的不知道该解决方案是什么,因此任何人都将不胜感激。在def password():函数中,password变量和password函数之间的名称用法不明确 当您到达密码函数时,密码是一个函数,而不是字符串。给其中一个起不同的名字。 import sys import string import time password = "1234" gues

当我有倒计时功能的密码不工作,只是不断循环。有人有办法吗


为了扩展倒计时功能,当我输入正确的密码时,它会说密码不正确,并在三次尝试后进入倒计时。我真的不知道该解决方案是什么,因此任何人都将不胜感激。

def password():
函数中,
password
变量和
password
函数之间的名称用法不明确

当您到达
密码
函数时,
密码
是一个函数,而不是字符串。给其中一个起不同的名字。
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()