DEV Community

Discussion on: How to copy a list in Python

Collapse
muhimen123 profile image
Muhimen

Yeah, I was thinking about that.

newlist = oldlist.copy()

Collapse
delta456 profile image
Swastik Baranwal

copy is a module where copy is a function not a method.

Thread Thread
paddy3118 profile image
Paddy3118

list objects have a .copy method.

Thread Thread
delta456 profile image
Swastik Baranwal

Yeah but I meant my how my example works. 😅