Write a program to demonstrate the three different ways of copying a list.
Answer:
Code:
import copy
list1=[
'red'
,
'green'
,
'blue'
,
'yellow'
,
'orange'
]
#method 1
list2= list1
print (list2)
#method 2
list3=copy.copy(list1)
print(list3)
#method 3
list4=list1[:]
print(list4)