I am an amateur programmer who is working on a console dice roller, quite more complex than the traditional ones. So far I am having trouble with this function:
def multiRoll(dice, amount):
total = 0
rolls = []
for roll in range(amount):
rolls += roll(dice)
total = sum(rolls)
return total, rolls
It is meant to take a single entry from a dictionary describing the kind of dice (4, 6, 8 faces, etc.) with its index and the times the dice is rolled. Then it rolls the dice as much as it is needed and then it is meant to add each result into a single list that will be summed later.
But apparently the flux goes wrong and when it reaches the this line:
rolls += roll(dice)
I get 'int' object is not callable.
May you please tell me how to overcome this?
If you have any doubt about the roll() function, here they are:
def roll(dice):
if dice < 1:
print "I found a problem when trying to roll a d%d" % (dice)
return "Failed"
else:
return randrange(1, dice)