我试图在掷骰子时使用while
循环而不是循环。for
我认为不elif
正确,但我无法弄清楚如何在其中使用while
循环。这是我到目前为止所拥有的:
import random
def rolldiewhileloop():
number = 10
one = 0
two = 0
three = 0
four = 0
five = 0
six = 0
while number > 0:
flip = int(random.random() * 6)
if(flip == 1):
one = one + 1
elif flip == 2:
two = two + 1
elif flip == 3:
three = three + 1
elif flip == 4:
four = four + 1
elif flip == 5:
five = five + 1
elif flip == 6:
six = six + 1
return [one, two, three, four, five, six]