If you reassign a variable will everything you've done previously with the variable (before you changed it) change as well? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If you reassign a variable will everything you've done previously with the variable (before you changed it) change as well?

1st Sep 2016, 2:53 PM
DELETED
3 Answers
+ 1
Short answer: No. Long answer: every program executes commands as is without getting ideas of it's own, unless you tell it to get ideas of it's own. That means the previous assignments remain valid and it's assumes the later assignments by executing the following commands. (sorry for the grammar. I'm a learner myself so my normal English is getting in the way of using technical terminology)
1st Sep 2016, 6:00 PM
Odogwudozilla
Odogwudozilla - avatar
0
Yes. Because the value of the variable will change. If at the start of the code you write "x = 2" and then later you write "x = 4". If you now print(x). Python will return 4.
17th Sep 2016, 12:31 AM
Eli Kerrison-Male
Eli Kerrison-Male - avatar
0
I feel python is like the military, obeys the last commands
17th Aug 2020, 12:03 PM
Clement Amobi