我的while循环有什么问题

时间:2017-01-15 18:20:02

标签: python

这是我正在处理的代码,但是当我执行它时,会在最后创建一个问题

restart = "No" or "no"
while restart == "No" or "no":

    print("League Registration")
    Fristname = input("What is first name?")
    Lastname = input("What is your Last name?")
    Nickname = input("What is your nick name?")
    Eaddress = input("What is your e-mail address?")
    Skill = input("What is your skill level, E for expert or C for casual?")
    if Skill  == "C" or Skill == "c":
        print("Casual")
    elif Skill == "E" or Skill == "e":
        print("Expert")


    print (" These are your personal details:")

    print ("First Name:",Fristname)

    print("Last Name:",Lastname)

    print("Nickname:",Nickname)

    print("Email Address:",Eaddress)

    print("Skill Level:",Skill)

    Detailscon = input("Are your personal details correct: Yes or No?")

    if restart == "Yes" or "yes":
        print("Thanl you , you are now registered")
    elif restart == "No" or "no":
        print("Try again")

我的代码到最后一直搞乱,我不知道该怎么做

1 个答案:

答案 0 :(得分:2)

代码中的错误就在这里。你看,在python中

    while (restart == "No") or "no":

操作员等于先评估,然后检查是否为真或字符串"否"超过零,它将永远运行。

而是将其更改为。

    while restart in ["No", "no"]: