New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Python question help me
Fitst sorry for my poor english skill Read this code: def func(x): x[0]=['def'] x[1]=['abc'] return id(x) q=['abc','def'] print(id(q)==func(q)) This code results in 'true' according to the question, but I can't get it why :( I think answer is false because order of component is changed through func() Isn't func(q) same as id(['def','abc']) ?? Why not?
2 Answers
+ 1
It doesn't change because id() return the address where the object is stored in the memory.
0
If you have a bit of time and want to understand more deeply, you might take a look into this tutorial I made a while ago:
https://code.sololearn.com/c89ejW97QsTN/?ref=app