Im a little new to python, so this question may be very easy to answer. However, the logic doesnt make sense to me which is why I am posting this question. While there have been similar questions asked, they all used large chunks of code that were hard to read. Here is the program in python:
list1 = [1,2,3,4,5]
list2 = list1
for i in range(len(list2)):
list2[i] += 1
print list1
When I run this program, it returns list1 as [2,3,4,5,6], which is identical to list2. My question is why list1 is connected to list2, and how to keep them independent of each other. Thank you for answering.