What exactly does += do in python?


I need to know what += does in python. It's that simple. I also would appreciate links to definitions of other shorthand tools in python.



+= is an add and assign operator in python. It adds the value of the left operand by the value given on the right, and then assign the new value back to the left operand. Here is an example of it.

a = 5

a += 20

print("a += 20 is", a)

The output will be,

a += 20 is 25

You can find all the available symbols and their definitions here - https://docs.python.org/3/genindex-Symbols.html



If you want to unleash your potential in this competitive field, please visit the Python course page for more information, where you can find the Python tutorials and Python frequently asked interview questions and answers as well.


This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.