遇到以下代码问题:
start_over = 1
question = input("Do you wish to try again? y/n: ")
if question == "y":
start_over -= 1
else:
raise SystemExit
如果他们输入y
,则直接进入else
条件。
解决了,是使用输入而不是raw_input
答案 0 :(得分:3)
只需定义start_over ......就可以了
question = raw_input("Do you wish to try again? y/n: ")
start_over = 10
if question == "y":
start_over -= 1
print start_over
else:
raise SystemExit