So, I was asked in class to use the specific random seed 237. But I don't know how to properly implement it. For example, this is my code. in python 3. In this example I'm basically throwing m number of dice with k number of sides and trying to return a tuple of m length.
import random
rng=random.seed(237)
# create random number generator
def throwDice(m, k):
x = 0
L = []
while x < m :
die = rng.randrange(1,k+1)
L.append(die)
x+=1
return print(tuple(L))
throwDice(11,5)
Yet, the command prompt keeps showing the error
die = rng.randrange(1,k+1)
AttributeError: 'NoneType' object has no attribute 'randrange'`
Could I get an explanation of what's wrong :(
Aucun commentaire:
Enregistrer un commentaire