Clarification on variables


Hey Guys new to python programming and just interested in a action in the tutorial,

just wondering in python how are you able to set a variable as in my_int = 7 then down the row

add anther variable my_int = 3 - then print the my_int to = 3 when their are 2 variables for my_int

my_int = 7

# Change the value of my_int to 3 on line 8!

my_int = 3

print my_int.

apologies if this seem mundane just differs from the logic of other programming i have done



This is actually one and the same variable, given multiple assignments. The last assignment is always the one that holds. Previous assignments are not preserved. We essentially overwrite them with the newest one. You will see this when you get to loops.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.