ibie808 ibie808 - 2 years ago 107
Python Question

Difference between "=" and "+=" on python?

What is the Difference between "=" and "+=" on python? (Without speech marks)
I've been experimenting, and I haven't found the difference...
I'm not fluent in python, however - I am on "A Day at the Supermarket" on Codeacademy.
Thanks for all your answers!

Answer Source

In python, the phrase x=4 will assign the value of 4 to x. However, the phrase x+=4 will increment 4 to the current value of x. For example:

x = 3
print x #will print 3
x += 2
print x #will print 5
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download