In the following python code, I have a list i.e. to_do_list
of two lists i.e. other_events
and grocery_list
where I inserted an item in grocery_list
and then deleted it.
My confusion is, when I updated grocery_list
, to_do_list
is automatically updated but when I deleted grocery_list
, to_do_list
is not updated... why?
grocery_list = ['banana', 'mango', 'apple']
other_events =['pick up kids','do laundry', 'dance class']
to_do_list = [other_events, grocery_list]
print(to_do_list)
grocery_list.insert(1,'onions');
print(grocery_list)
del grocery_list
print(to_do_list)
its output is:
[['pick up kids', 'do laundry', 'dance class'], ['banana', 'mango', 'apple']]
['banana', 'onions', 'mango', 'apple']
[['pick up kids', 'do laundry', 'dance class'], ['banana', 'onions', 'mango', 'apple']]