In the Boredless Tourist Project, Instruction 32
attraction passed into
add_attraction to the list
That’s all we want this function to do, so we can
return after adding the attraction to the list.
I wonder how/why to append a new item in a variable containing a sublist of the main list also add the new item in the main list, the code is as follows:
def add_attraction(destination, attraction):
How is that the following code append a new attraction in both lists, “the attractions_for_the_destination” and the main list “attractions”
the append is over attractions_for_the_destination, I would think the attractions list wouldn’t be changed but it is, when I print attractions_for_the_destination and attractions both have the new item
I tested it with other lists and happened the same, append a new item in a variable containing a sublist of a main list adde the new item in both
Could someone explain the logic behind it?