[英]Rolling 5 dice in python
我得到了:
def rollDice(dice, toRoll=[0,1,2,3,4]):
"""Rolls specified dice. If no dice are specified, all dice are rolled."""
for i in toRoll:
dice[i] = random.randint(1,6)
在我的一生中,我无法弄清楚如何调用此函数掷出五个骰子。 我已经尝试过rollDice(5,toRoll)和其他一些变化。 我也有其他地方的回线
该函数将写入其第一个参数。 尝试这个:
dice = [None] * 5
rollDice(dice)
print(dice)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.