How to Make a Copy of a List in Python


In this example we will show how to make a copy of a list with the list() method in Python.

Source Code

my_list = ['a', 'b', 'c', 'd', 'e']
my_list_2 = list(my_list)
print(my_list_2)

Output:

['a', 'b', 'c', 'd', 'e']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

How to Make a Copy of a List in Python


In this example we will show how to make a copy of a list with the copy() method in Python.

Source Code

my_list = ['a', 'b', 'c', 'd', 'e']
my_list_2 = my_list.copy()
print(my_list_2)

Output:

['a', 'b', 'c', 'd', 'e']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments