Why does
num_list = [1, 2, 3, 4, 5]
first_num = num_list[0]
first_num = 0
print(num_list)
returns [1, 2, 3, 4, 5]
, but
dict_list = [{"num": 1}, {"num": 2}, {"num": 3}, {"num": 4}, {"num": 5}]
first_dict = dict_list[0]
first_dict["num"] = 0
print(dict_list)
returns [{'num': 0}, {'num': 2}, {'num': 3}, {'num': 4}, {'num': 5}]
?
In other words, why assigning a variable to a list element, and modifying that variable, would cause that element to be modified only if it's a dict and not a number? I think this might be due to the way numbers and dictionaries are stored in Python, but being a Python beginner, I'm not sure sure where to look for an answer.
I'd really appreciate your help for me to understand this distinction!