0
Variable assignment
Hello! Why I got the output 67 in both the variable from this code? Should not be 67 only in xx_aa[3] and 56 in xx_bb[3]? xx_aa =[2,3,'hello', 56] xx_bb = xx_aa xx_aa[3] = 67 print(xx_aa[3]) print(xx_bb[3]) Thanks! Luca
3 Respostas
+ 2
The code you shared should print the whole list twice with the updated value at 3rd index. I think you have missed the index in the print statement.
Edit: Also it would print 67 in both the cases because you have assigned xx_aa to xx_bb which means there are two variables pointing to a single list so the change made using one variable will be reflected in the other.
0
Hi Avinesh, you are right, I correct the code but the question remain...
and is not working in the same way when 2 variables are pointing at the same integer or string?
0
Tonno I have edited the answer.