密码输入错误时,如何使代码恢复打印(“请输入密码,管理员...”)?

时间:2019-05-23 00:32:46

标签: python

我想让我的代码返回到询问密码(如果输入错误)。另外,我正在尝试添加一项功能,当我键入该功能时,它会返回到先前的代码,

我尝试在True:循环时进行。但是,我还没有完全正确。

password = "a"

print("Please enter your password, Admin...")`

input1 = input()

while True:
    input1 == password
    print("What\'s your name?")

else:
    print("Password Incorrect...")
    import sys
    sys.exit()

name = "alex"
name2 = "dylan"

input2 = input()

if input2 == name or "Alex":
    print("Hello creator," + " please improve me!")

elif input2 == name2 or "Dylan":
    print("Why hello there Sir,", name2, ", I have been expecting you...")

else:
    print("You were not expected, please leave...")

    import sys
    sys.exit()  

如果程序停止, 如果正确,则通过。

0 个答案:

没有答案