I can't understand while comparing between two codes. output of a
is 7 and b
is 5, which is correct. But 2nd code, why does another_list
show ['egg', 'rice', 'milk', 'bread', 'butter', 'chicken', 'pasta']
in the output? print(another_list)
should show ['egg', 'rice', 'milk', 'bread', 'butter', 'chicken']
only, because I have commented out the line another_list = shopping_list
.
a = 5
b = a
a += 2
print(a)
print(b)
print()
shopping_list = ["egg",
"rice",
"milk",
"bread",
"butter",
"chicken"]
another_list = shopping_list
shopping_list += ["pasta"]
print(shopping_list)
######another_list = shopping_list
print(another_list)