Not adding up
-
I am writing a program that I input the results of a dice throw and press a button and it adds all dice results together.
Dice1 = input("Dice One Result, false")
Dice2 = input("Dice Two Result, false")
Dice3 = input("Dice three Result, false")
//this is done in a functionThe press B button to add the three dice results together.
Result = dice1+dice2+dice3
//this is done in a different functionSay dice1 = 2, dice2 = 5 and dice3 = 1
As you would expect you would get a result of 8 but I'm not it gives me a result like thisResult = 251
I can't understand why it's doing it this way and even reading the fuze help doesn't help.
Can somebody please help me with this?Thanks in advance.
-
@daneeboy I believe it's treating the numbers you get from
input()as strings so when you 'add' them it just sticks one after the other. You could try usingint()to convert from strings, either when you first take the inputs or when you add them together, eg.Dice1 = int( input("Dice One Result, false") )
or
Result = int(dice1) + int(dice2) + int(dice3) -
@kat thank you I will give that a try.