Hello, I want to duplicate a list in python. The way I want is, I need two list with same content pointing to different memory Location. What I tried is

Dup_List = Original_List[:]

, but lookes like even this is making both list point to same memory location.

Both the List are 2D

Thanks in advance

mylist1 = [1, 2, 3]

mylist2 = mylist1[:]

print(id(mylist1))
print(id(mylist2))

''' result show 2 different memory locations ...
42368056
34857768
'''
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.