0

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

Edited by ram619

3
Contributors
2
Replies
30
Views
3 Years
Discussion Span
Last Post by vegaseat
0
mylist1 = [1, 2, 3]

mylist2 = mylist1[:]

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

''' result show 2 different memory locations ...
42368056
34857768
'''
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.