我有下面的代码,输入我的名字后,它跳过函数中的所有内容,直接转到“欢迎…”部分。在
import time
print("Hello. Please enter your name, then press 'enter' ")
username = input()
print("Hello " + username)
time.sleep(2)
def game_tutorial_input():
while True:
tutorial_answer = input("Do you wish to see the tutorial?"
"(y/n) ")
if "y" in tutorial_answer:
input("Great! Press enter after each instruction to move"
"onto the next one.")
input("To answer each question, type one of the given"
"options depending on what you want to select,"
" then press enter.")
input("Wow, that was short tutorial!")
else:
print("Alright!")
continue
return
time.sleep(2)
print("Welcome, " + username + ", to Indiana")
我怎样才能解决这个问题?在
是的,只需要调用函数
正如其他人指出的一些其他问题一样,你不能在函数中返回任何东西,你的循环不会退出whiletrue永远不会“中断”
你可以这样考虑:
^{pr2}$或更完整的处理:
相关问题 更多 >
编程相关推荐