Python如何回到主菜单

时间:2017-05-19 12:13:27

标签: python

这是我的代码我希望它在按下按钮

后返回主菜单
numberoftries = 3
while numberoftries > 0:
    print("You have 3 tries")
    username =(input("Enter the username"))
    password = (input("Enter the password"))
    if (password) == "password" and (username) == "MrLee123":
        import time
        time.sleep(1)

        print("Username and password accepted")
        print("Choose a student")
        print("1.) Hanif Adolecense")
        print("2.) Kerlo Sumpage")
        print("3.) Kearien Honter")
        print("4.) Mex Whitermen")
        print("5.) Tolu Ohyeahbola")
        print("Press enter to quit")
        answer = input("Select an option")
        numberoftries = 0
        if answer == "1":
                print("Hanif Adolescense")
                print("ID Number:12376")
                print("Surname: Adolescense")
                print("Forename: Hanif")
                print("DOB: 24 Dec 2001")
                print("Address: Somewhere in Nigeria")
                print("Number: ")
                print("Gender: Male")
                print("Tutor group: G")
                print("School email: 13h.adolecense@dallam.com")

如何从1回答菜单

1 个答案:

答案 0 :(得分:0)

if级别添加:

else:
    number_of_tries -= 1

这会在3次不成功的尝试后破坏诡计。然后在while循环之后调用任何将用户移动到主要意义的东西。