I don't get what's wrong with this code
I keep getting a value error when i run this
it says
Traceback (most recent call last):
File "rolling.py", line 40, in <module>
dice1, dice2, dice3 = numb(dice)
ValueError: need more than 2 values to unpack
please help?
def numb(dice):
if dice == 1:
dice1 = random.randint(1, 6)
return dice1
elif dice == 2:
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
return dice1, dice2
elif dice == 3:
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
dice3 = random.randint(1, 6)
return dice1, dice2, dice3
else:
print "Invalid"
dice1, dice2, dice3 = numb()
if dice == 1:
print "You got " + str(dice1)
elif dice == 2:
if dice1 == dice2 :
print "2 matches"
else:
print "0 matches"
print "You got " + str(dice1) + " and " + str(dice2)
print "Sum is " + str(dice1 + dice2)
elif dice == 3:
if dice1 == dice2 == dice3 :
print "3 matches"
elif dice1 == dice2 :
print "2 matches"
elif dice2 == dice3 :
print "2 matches"
elif dice1 == dice3 :
print "2 matches"
else:
print "0 matches"
print "You got " + str(dice1) + " and " + str(dice2) + " and " + str(dice3)
print "Sum is " + str(dice1 + dice2 + dice3)