player_input = '' # This has to be initialized for the loop
while player_input != 0:
player_input = str(input('Roll or quit (r or q)'))
if player_input == q: # This will break the loop if the player decides to quit
print("Now let's see if I can beat your score of", player)
break
if player_input != r:
print('invalid choice, try again')
if player_input ==r:
roll= randint (1,8)
player +=roll #(+= sign helps to keep track of score)
print('You rolled is ' + str(roll))
if roll ==1:
print('You Lose :)')
sys.exit
break
我试图告诉程序如果roll == 1
没有发生任何事情就退出,当我尝试使用时它只会给我一条错误消息sys.exit()
这是我运行程序时显示的消息:
Traceback (most recent call last):
line 33, in <module>
sys.exit()
SystemExit