Why is the output of the following code = [1,[2,5]]?
a = 3
a = 5
9/1/2019 6:15:26 PM
b = a[:]
copies all indexes to b, since a is a list the refernce to that list get copied. when you now edit a the change is in b too.
you perhaps should use:
b = copy.deepcopy(a)
Sorry about that, that was my first question, I didn't think about that, my bad
Please mention the language in Relevant Tags rather than a sentence or question 'why on the following scrip,'. Proper use of tags helps improve search feature quality 👍
I understand, just reminding you in case you forget, no problem buddy 👍
GET THE FREE APP
Learn Playing. Play Learning
Send us a message