What is the difference between these two methods;
# Solution 1
list1 = ['a', 'b', 'c', 'd']
temp_list1 = list1
for i in range(len(list1)):
temp_list1[i] = "1"
print list1; # ['1', '1', '1', '1']
print temp_list1; # ['1', '1', '1', '1']
# Solution 2
list2 = ['a', 'b', 'c', 'd']
temp_list2 = list2
temp_list2 = ['1', '1', '1', '1']
print list2; # ['a', 'b', 'c', 'd']
print temp_list2; # ['1', '1', '1', '1']
By using solution1, want to update the temp_list1 with some other value at the same time want to retain the old value in list1. But this updated the both lists.