Nov-19-2019, 11:55 PM
(This post was last modified: Nov-19-2019, 11:55 PM by leodavinci1990.)
#What is the output? val=100 print(val) def changeVal(): val=99 print(val) changeVal() print(val) #What is the output? vals=[100,100,100] print(vals) def changeVals(): vals[0]=99 print(vals) changeVals() print(vals)So I understand this as an example of pass by reference and pass by value.
The output is:
100
99
100
[100, 100, 100]
[99, 100, 100]
[99, 100, 100] #last line
1) Why isn't the last line [100,100,100]?
2) This is not a scope thing. Correct?