嗨我一直在构造这段代码,但是当骰子落在一个骰子上时我需要停止while循环。当randint = 1时,我该如何停止while循环
from random import randint
min = 1
max = 6
roll=input ('care to roll?')
while roll == ('yes' or 'Yes'):
print ("rolling...")
print randint(min,max)
print randint(min,max)
while randint (1):
break
else:
continue
if roll == ('no' or 'No'):
print ("fine then, see if I care")
你究竟想在这里完成什么?停止执行while循环的方法是添加'while while result!= 1'等条件。您可以将throw的结果存储到变量'result = randint(min,max)' –
请注意,'while roll ==('yes'或'Yes')'是**没有做你认为它正在做的事** –
考虑检查'roll.lower()'对一个值 –