我到处找我的问题的答案,但还是找不出来!答案可能很简单,但我就是搞不懂,可能是因为我刚刚回到Python。。。你知道吗
无论如何,我想创建一个while循环,这样在用户输入“y”或“n”之前,问题将一直被询问。这就是我所拥有的:
while True: # to loop the question
answer = input("Do you like burgers? ").lower()
if answer == "y" or "n":
break
我真的很受宠若惊,所以我请求别人的帮助:)
Tags:
你的情况不对。另外,如果您使用的是Python2.x,那么应该使用
raw_input
(否则您需要键入"y"
,而不是y
,例如):相关问题 更多 >
编程相关推荐