Why is a variable not updating after changing its dependent variable? [duplicate]
问题 This question already has answers here : Are python variables pointers? or else what are they? (9 answers) Closed 8 months ago . I don't understand why the variable 'y' doesn't update when I change the x? (The 'y' variable is dependent on 'x' right?) x = 5 y = x*2 print(x) print(y) x = 3 # Expect it to print '3' and '6' instead it print '3' and '10' print(x) print(y) 回答1: (The 'y' variable is dependent on 'x' right? No. Few programming languages have dependent / computed variables [0] and