I know this is a very simple question, but I couldn't find it. Basically what I'm trying to is have a=2, b=3, and I need a+b=b so when I add a and b what it equals needs to be b.
4 Answers
declare variables
a = 2
b = 3
operates
b = a+b
1 Comment
Eric O. Lebigot
You can even recommend the usual
b += a.Here is a quick example:
First, initialize your variables:
a = 2
b = 3
print a, b
Output: 2 3
You can add a to b, this way:
b += a
print b
Output: 5
You can also add to the actual value of b 10
b = 10+b
print b
Output: 15
1 Comment
Eric O. Lebigot
Side note: I encourage you to read and follow PEP 8: it contains Python style recommendations that are widely followed. This will make your code more legible (I fixed the style in your answer so that it follows the common convention).
b = a + bis what you're looking for, orb += a