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
您在
if
块内定义password
,因此如果if
块不执行,password
将保持未定义状态。此外,您的list_names
语法不正确。更新至
前者执行
相关问题 更多 >
编程相关推荐