+ 2
Challenge question
Here is code from a challenge question. The answer is 10, but I need some help with the reasoning. List1 is passed to the guess function, then list2 is a copy of list1, then appends 4 to the end of list2 which in turn appends it to the end of list1. I thought everything was fine until the assignment to list1. How does that not change the value of list1 before the print statment? https://code.sololearn.com/c3OfxnSLGJIq/?ref=app
2 Answers
+ 1
Run the code and check, if you still can't understand then let us know.
https://code.sololearn.com/cp917ZSBHD3N/?ref=app
+ 1
So the new assignment for list1 references a different memory location.