Python List append()

The append() method in Python adds an element to the end of the list. After appending the new element, the size of the list increases by one.

In this tutorial, we will learn about the Python list append() method with the help of examples.

Syntax of List append() 

The syntax of the append() method is:


append() Parameters

The append() method takes a single parameter.

  • item – an item to be added at the end of the list. The element can be of any data type such as number, decimal, string, character, list etc.

Return Value from List append()

The append() method doesn’t return any value.

Note: A list is an object. If you append another list onto a list, the element list that gets added will be a single object at the end of the list.

Example 1: Adding Element to a List

# Programming list
programming_list = ['C','C#','Python','Java','JavaScript']

# append the HTML item to the list
print('The new list is :', programming_list)


The new list is : ['C', 'C#', 'Python', 'Java', 'JavaScript', 'HTML']

Example 2: Adding List into the List

Since we are appending a list into an existing list it would be added as a single element into the list as shown in below output.

# Programming list
programming_list = ['C','C#','Python','Java']

frontend_programming =['CSS','HTML','JavaScript']

# append the frontend_progamming list into the existing list

# Note that entire list is appended as a single element
print('The new appended list is :', programming_list)


The new appended list is : ['C', 'C#', 'Python', 'Java', ['CSS', 'HTML', 'JavaScript']]
Leave a Reply

Your email address will not be published.

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like
Nxnxn Matrix Python

nxnxn matrix python

Table of Contents Hide What is NxNxN?How to Create NxNxN Matrix in Python?Create NxN Matrix in Python 3 with Non Duplicating numbersCreate NxNxN matrix in Python using numpy In this…
View Post
Typeerror Unhashable Type 'Dict'

TypeError: unhashable type: ‘dict’

Table of Contents Hide TypeError: unhashable type: ‘dict’Solution to TypeError: unhashable type: ‘dict’.By Converting into a tupleBy Adding Dictionary as a value in another dictionary In Python, all the dictionary…
View Post
How To Check If A File Exists In Python

How to check if a file exists in Python?

Table of Contents Hide Python check if a file exists using OS ModuleUsing os.path.exists()Using os.path.isfile()Using os.path.isdir()Using pathlib.Path.exists() When you perform a file operation such as reading from a file or…
View Post
Sort Dictionary By Value In Python

Sort Dictionary by value in Python

Table of Contents Hide Python sorted() function to rescueSyntax: sorted(iterable, key, reverse)Sort a Dictionary by ValueExample 1: Basic Sorting in PythonExample 2 : Sorting different Data Types in PythonExample 3: Sort…
View Post
Python String Count()

Python String count()

Table of Contents Hide count() Syntaxcount() Parameter count() Return ValueExample 1: Count the number of occurrences of a given substring without optional argumentsExample 2: Count the number of occurrences of a…
View Post