Help with this code not able to understand output
list1 = [10,โโ] list2 = [123] list3 = [ โaโ]
Okay @sarthaktech23, one thing that should note here is that when list1 is created in the 5th line, the list gets a value of 10. When you create list2 in the 6th line, itโs easy to understand that we are sending our own empty list along with the 123, an hence list2 contains the element 123. But now when we create list3 in the 7th line, you must note that since we are not sending any default empty list in the function call ( we are just sending a single element โaโ) , the letter โaโ gets appended to the same list that was created when we had created list1. Thatโs the reason when you print the final output of all the three lists, you get something like this
[10, 'a']
[123]
[10, 'a']
list1 and list3 are the same lists.
I hope this clears your doubt !
Happy Coding !
I hope Iโve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.