DEV Community

What is the Meaning of += in Python?

DDSRY on August 31, 2020

Meaning of += in Python Programming language? Do you know how in English we can rewrite "it is" to be "it's"? Or we can rewrite "you are" to "yo...
Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Officially, this is known as a "compound operator", and there's one for each of the five basic math operators in Python:

x = 5

x += 2  # 7
x -= 1  # 6
x *= 5  # 30
x /= 2  # 15
x %= 2  # 1

P.S. You'll want to drop the #help tag from your post, as that's only for questions. #beginners might be a good fit, though.