mercredi 17 février 2021

Adding two values puts them side by side instead of sum

I am making a game where I need to add two dice variables.

import random

dice = ["1", "2", "3", "4", "5", "6"]
dice1 = random.choice(dice)
dice2 = random.choice(dice)
all_dice = dice1 + dice2
print("You rolled a total of " + all_dice + ".")

But the outcome doesn't add them, they put the variables side by side, like (ab) not (a+b).

Does anyone know how to get the all_dice variable to (a+b) and not (ab)?




Aucun commentaire:

Enregistrer un commentaire