Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

Python copy List Function

by suresh

Python copy List is one of the List methods used to shallow copy a Lists. I mean, copying list into a new list. The syntax of the list copy function is

list_name.copy()

Python List copy Function Example

The copy function copies total items in a given list to a new list. The below code copy list a to newList.

# Python Copy List Function

a = [10, 20, 30, 40]

print("Original List : ", a)
newList = a.copy()
print("Copied List   : ", newList)
Python Copy List Function 1

In this list copy example, we declared a string list. Next, we used the copy function on it.

TIP: Please refer to List and List methods articles in Python.

# Python Copy List Function

strFruits = ['Apple', 'Banana', 'Kiwi', 'Grape']

print("Original List : ", strFruits)
newList = strFruits.copy()
print("Copied List   : ", newList)
Python Copy List Function 2

copy List Function Example 2

Let me use this list copy function on Mixed List.

# Python Copy List Function

MixList = ['apple',  1, 'Banana', 5, 'Kiwi', 'Mango']

print("Original List : ", MixList)
newList = MixList.copy()
print("Copied List   : ", newList)
Python Copy List Function 3

List copy Function Example 3

In this program, we used List copy function on the Nested list (list inside a list).

# Python Copy List Function

MixList = [[71, 222], [222, 13], [14, 15], [99, 77]]

print("Original List : ", MixList)
newList = MixList.copy()
print("Copied List   : ", newList)
Python Copy List Function 4

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python Numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python Substring
  • Python Programming Examples
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy