【发布时间】:2017-09-29 14:56:58
【问题描述】:
我做了一个魔术 8 球程序,但是我不知道如何从魔术 8 球函数返回到玩家函数。 `
def gamer():
choice = int(input("What game do you want to play? \n[1]Magic 8 Ball \n[2]Dice?\n[3]Exit \n"))
if choice == 1:
def magic8ball():
import random
print("\nWelcome to the Magic 8 Ball Program. Input your question and hit enter for the 8 ball to respond")
print("What is your question?")
userinput = input()
choices = ["It is certain", "It is decidedly so", "Without a doubt", "Yes definitely", "You may rely on it", "As I see it, yes",
"Most likely", "Outlook good", "Yes", 'Signs point to yes', "Reply hazy try again", "Ask again later", "Better not tell you now",
"Cannot predict now", "Concentrate and ask again", "Dont count on it", "My reply is no", "My sources say no", "Outlook not good", 'Very doubful']
if userinput != "exit" or "EXIT" or "Exit":
print(random.choice(choices))
if userinput == "exit" or "Exit" or "EXIT":
#Where I need help
magic8ball()
while True:
magic8ball()
continue`
【问题讨论】:
-
请修正缩进
-
欢迎来到 SO。请花时间阅读How to Ask。
标签: python python-3.x