clone a list in python code example
Example 1: copy one list to another python
thislist = ["apple", "banana", "cherry"]
mylist = thislist.copy()
print(mylist)
Example 2: python copy list
a=[1,2,3,4]
b=a[:]
''' now b has all elements of a'''
thislist = ["apple", "banana", "cherry"]
mylist = thislist.copy()
print(mylist)
a=[1,2,3,4]
b=a[:]
''' now b has all elements of a'''