python程序登录不工作

2024-04-19 22:32:41 发布

您现在位置:Python中文网/ 问答频道 /正文

list_names = ("A"+"B"+"C")
username = input("enter your username: ")
if username == (list_names):
    password = input("enter your password "+username+": ")
elif username !=(list_names):
    print("that is not a valid username")
if password == ("password"):
    print("allowing access...")
    time.sleep(3)
elif password != ("Password"):
    print("password was incorrect "+username)

我试图为我正在做的一个项目制定一个计划,但我遇到了一个问题。我已经尝试了很长一段时间,为什么这不起作用,但我无法理解为什么它打印这个错误:

Traceback (most recent call last):
  File "C:\Users\Owner\Documents\PYTHON\My Work.py", line 10, in <module>
    if password == ("password"):
NameError: name 'password' is not defined

Tags: inputyourifthatnamesisusernamenot