- 1

What is the different between in-place operator and variables in python

9th Mar 2021, 10:56 AM
Shamson Yacoub
Shamson Yacoub - avatar
2 Respuestas
+ 3
You are comparing two completely different things here: In-place operator is also about variables. It's just another way to change the value of a variable. x = x + 2 Here we create a new value from x + 2 and then give it the name x. (The old x is lost now.) x += 2 Here we change x directly.
9th Mar 2021, 11:03 AM
HonFu
HonFu - avatar
+ 2
variables are identifiers used to refer to some memory emplacement... in-place operators are shortcut to assign result of operation between at least one variable and some expression (with or without variable)... my_var = 36 # simple assignement my_var += 6 # same as my_var = my_var+6
9th Mar 2021, 11:03 AM
visph
visph - avatar