重新启动的自动食品站

时间:2018-10-25 16:25:50

标签: python

我需要创建一个自动的冰淇淋站,询问客户的名称以及他们是否需要冰淇淋,如果客户说在输出客户的名称和“您没有得到冰淇淋”的一行后没有程序重启。如果客户回答“是”,程序将继续询问是否要巧克力打顶,撒巧克力和餐巾纸。必须重新启动才能允许多个输入。

如果客户说“否”,我无法重启程序。它要么循环回答问题,要么不问答案,或者即使在“否”之后仍继续回答其他问题。如果我现在说“否”,它将重新启动,但是在“是”之后我无法使其重新开始。如果我缩进最后一行,则在运行时它什么也不显示。

def main():
    custname = input("Please enter your name: ")
    icecream = input("Would you like Ice Cream? ")
    if icecream == "No" or icecream == 'no':
        print(custname + "\nYou are not getting Ice Cream.", sep = "\n")
        main()
    choctopping = input("Would you like Chocolate Topping? ")
    sprinkles = input("Would you like Sprinkles? ")
    napkin = input("Would you like a Napkin? ")

    if icecream == "Yes" or icecream == "yes":
        print(custname + "\nYou are getting Ice Cream.", sep = "\n")
    if choctopping == 'Yes' or choctopping == 'yes':
        print("You are getting Chocolate Topping")
    elif choctopping == 'No' or choctopping == 'no':
        print("You are not getting Chocolate Topping")
    if sprinkles == 'Yes' or sprinkles == 'yes':
        print("You are getting Sprinkles")
    elif sprinkles == 'No' or sprinkles == 'no':
        print("You are not getting Sprinkles")
    if napkin == 'Yes' or napkin == 'yes':
        print("You are getting a Napkin")
    elif napkin == 'No' or napkin == 'no':
        print("You are not getting a Napkin")

main()

我对Python还是很陌生,我只从朋友从她的班级获得的作业中学到东西,然后尝试自己和Google解决我需要帮助的地方。但是不幸的是,谷歌在这里没有帮助。

0 个答案:

没有答案