It just seems that instead of:
for i in range (numRolls):
rv= rollDice(numDice, numSides )
rolls[rv]+=1 #where I keep on getting the error at :(
you need:
for i in range (numRolls):
rv = rollDice(numDice, numSides)
for dice in rv:
rolls[dice] += 1
Your rollDice
returns results for numDice
dices (a list
). Then you try to index the rolls
list with another list, which doesn't make any sense (and that's what the error is saying exactly).
You can also change the method to return only one result, for one dice:
def rollDice(numSides):
return random.randint(1, numSides)
So your version of counting code will work. Depends on what you want.