Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
When reassigning value to a variable, will the interpreter run with the old value up until the point of the new value?
If you had previously assigned this value for example in the first line of your code: dessert = "ice cream" and you used the variable dessert several times until let's say line 15 of your code where you reassign a new value to that variable: dessert = dessert + " and cookies" will the script be run with the new value after that point and with the old value before that point even though they technically have the same variable name?
Daniel Svens6,030 Points
Yes (If i understood you question correctly), You can try it like this.
dessert = 'ice cream' print(dessert) # ice cream dessert = dessert + ' and cookies' print(dessert) # ice cream and cookies
Sumiya Malik3,964 Points
Yes, Consider the variables as boxes. For example you have 3 boxes and you named them as b1, b2, b3 and data types as fruits(in this case). Now you added an apple in b1. So you have an apple in that box until and unless you replace it with another value, lets take orange. So the value apple will be replaced by orange. and it will have the orange in it until you replace it with something else. b1="apple" print(b1) b1="orange" print(b1) Hope that helps!