friends = ["kevin", "karen", "jim", "jim", "jim", "oscar", "toby"] friends = friends.copy() print(friends)
friends2 = friends.copy() AttributeError: 'list' object has no attribute 'copy'
I use Python 3.x and before posting this message I read few suggestions which pop up when I enter the title. I found a StackOverflow article wrote by @Shemogumbe The list.copy method does not work both in python 2.x and python 3.x
Also, it looked into Pythons Offical documentation on copy function
it also says use
copied_list = original_list[:] when I use this my VScode compiles without any error.
Hence my question is should I use
friends2 = friends.copy() or
friends2 = friends[:]