完成任务的python代码时出现问题
您好,我最近开始学习python,并在互联网上搜索了12个小时的帮助,试图完成这项任务(它一直困扰着我,lol)。有人能帮我完成这项任务吗,或者至少能告诉我目前编写的代码哪里出了问题 提前谢谢你完成任务的python代码时出现问题,python,loops,while-loop,Python,Loops,While Loop,您好,我最近开始学习python,并在互联网上搜索了12个小时的帮助,试图完成这项任务(它一直困扰着我,lol)。有人能帮我完成这项任务吗,或者至少能告诉我目前编写的代码哪里出了问题 提前谢谢你 这应该是你想要的 while True: resp = input("Would you like some advice?") if resp not in ["Y", "N"]: print("Please enter Y or N only.") elif
这应该是你想要的
while True:
resp = input("Would you like some advice?")
if resp not in ["Y", "N"]:
print("Please enter Y or N only.")
elif resp == "Y":
print("Don't feed the trolls!")
break
else:
print("Don't be silly, you definitely need advice!")
如果您使用的是python 2,请将
input
更改为raw\u input
如果您需要帮助,建议共享代码,解释错误并共享您尝试过的内容。