jeudi 19 octobre 2023

If a variable has two values, how do I add the different values together? [closed]

So, I have one variable that has a random.randint, and I run it twice. Obviously both times have a different number (unless you get lucky lol). And I'm trying to add two separate numbers together with only one variable.

The variable is called start, and so I do something that looks like this:


Sum = (start + start)

Print(sum)

I put this inside of a for loop that runs twice.

When I run it, the result I get is the first number added to itself, and then the second number added to itself. What I'm trying to do is get the separate numbers added. This is part of a much larger thing and so I can't be bothered creating two separate variables so is there a way to make it so that it adds the first number and the second number together without having to make two distinct variables?




Aucun commentaire:

Enregistrer un commentaire