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 append List Function

by suresh

Python append List is one of the List functions used to add an item to the end of an old list. In this section, we discuss how to use this append function on the list with practical examples.

The syntax of this Python append List function is:

list.append(New_item)

This list append method help us to add given item (New_item) at the end of the Old_list

Python append List Function Example

First, we declared an integer list with four integer values. Next list append code adds 50 to the end of List a

TIP: Please refer to List and List functions articles to understand everything about Lists in Python.

# Python Append List Items

a = [10, 20, 30, 40]

print("Original List Items are : ", a)
a.append(50)
print("List Items are          : ", a)

OUTPUT

Python Append List Items 1

append List Function Example 2

In this program, we are adding three integer values to an integer list using this list append function.

# Python Append List Items

a = [10, 20, 30, 40]

print("Original List Items are : ", a)
a.append(50)
a.append(60)
a.append(70)
print("List Items are          : ", a)

OUTPUT

Python Append List Items 2

Python List append Example 3

This example shows you the working functionality of the list append function on a string list.

In this example, we declared a string list. Next, we used the list append function to add another fruit to this list.

# Python Append List Items

Fruits = ['Apple', 'Orange', 'Kiwi', 'Grape']

print("Original List Items are : ", Fruits)
Fruits.append('Banana')
print("List Items are          : ", Fruits)

OUTPUT

Python Append List Items 3

List append Function Example 4

This program is the same as the first list append example. However, this time, we are allowing the user to enter the length of a List. Next, we used For Loop to append those numbers to the list.

# Python Append List Items

intList = []
 
number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, number + 1):
    value = int(input("Please enter the Value of %d Element : " %i))
    intList.append(value)
    
item = int(input("Please enter the New Item to append : " ))
print("Original List Items are : ", intList)
intList.append(item)
print("New List Items are      : ", intList)

OUTPUT

Python Append List Items 4

List append Function Example 5

In this program, we used the list append function to add words to a list

# Python Append List Items

strList = []
 
number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, number + 1):
    value = input("Please enter the Value of %d Element : " %i)
    strList.append(value)
    
item = input("Please enter the New Item to append : " )
print("Original List Items are : ", strList)
strList.append(item)
print("New List Items are      : ", strList)

OUTPUT

Python Append List Items 5

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