Python Copying a list - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Python Copying a list - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Thursday, December 6, 2018

Python Copying a list

Python Copying a list




Copying a list

To copy a list make a slice that starts at the first item and ends at the last item. If you try to copy a list without using this approach, whatever you do to the copied list will affect the original list as well.

#Making a copy of a list
finishers =['kai', 'abe', 'ada', 'gus', 'zoe']
copy_of_finishers = finishers[:]
print(copy_of_finishers)

Screenshot

python copy list

 

No comments:

Post a Comment

Post Top Ad