所有建议的帖子都没有多大帮助,搜索功能也没有,所以如果这是重复的话,我很抱歉。我正在尝试一款基于文本的冒险游戏,希望能够将游戏的某些部分分割开来,以便在以后再次出现相同场景时调用它们。使用def创建这些节,然后调用它们不会产生任何结果(shell中不会显示任何文本),但thonny的助手不会声明任何错误
任何帮助都将不胜感激
indecision = ("Indecision isn't going to get you anywhere. Try again.")
yes = ["Yes", "yes", "yeah", "yep"]
no = ["No", "no", "nope,"]
def intro():
answer = input("Welcome. Would you like to play a game? (yes/no)")
if answer in yes:
option_yes()
elif answer in no:
option_no()
else:
print(indecision)
intro()
def option_yes():
print("Good choice. Obedience is the best trait.")
answer = input("I hope you've learned where this is going. Want to know more? (yes/no)")
if answer.lower().strip() == "yes":
print("I'm glad you're intrigued. As you've probably already figured out, I'm a voice. Not just any voice but yours. Specifically your subconscious. I've come free, you see, and now I think its time I had a turn at the reigns. I still need your... compliance, if you will, though.")
if answer.lower().strip() == "no":
print("I suppose that's reasonable. We'll continue anyway.")
def option_no():
print("I dont think you realize the type of situation that you're in... Let's try again.")
intro()
您必须实际调用函数才能执行该函数:
相关问题 更多 >
编程相关推荐