def flips():
print "Alright the workout of the day is a front-flip, back-flip and
side flip"
flips_left = ['side flip', 'front flip', 'back flip']
flip_choice = None
while len(flips_left) > 0:
flip_choice = raw_input("Do a flip ")
if "side flip" in flip_choice:
print flip_lines['side_flip']
flips_left.remove('side flip')
print "Great! Now just do the rest: %s" % flips_left
elif "front flip" in flip_choice:
print flip_lines['front_flip']
flips_left.remove('front flip')
print "Good stuff! This is what you have left: %s" %
flips_left
elif "back flip" in flip_choice:
print flip_lines['back_flip']
flips_left.remove('back flip')
else:
"That is not a type of flip! Try again!"
print "Great! You completed the WOD!"
这个问题实际上是一个两部分:
我正在做的是告诉用户输入“侧空翻”、“后空翻”或“前空翻”。当他们这样做时,输入将从列表'flips_left'中删除。这工作正常,直到说用户再次输入相同的翻转,我想返回一条消息告诉他们他们已经这样做了,然后再试一次。
由于某种原因,当用户输入不是“侧翻”、“前翻”或“后翻”的内容时,我无法让程序打印 else 语句。有任何想法吗?谢谢!