Python 3 - List append() Method


Advertisements

Description

The append() method appends a passed obj into the existing list.

Syntax

Following is the syntax for append() method −

list.append(obj)

Parameters

obj − This is the object to be appended in the list.

Return Value

This method does not return any value but updates existing list.

Example

The following example shows the usage of append() method.

#!/usr/bin/python3

list1 = ['C++', 'Java', 'Python']
list1.append('C#')
print ("updated list : ", list1)

Result

When we run above program, it produces the following result −

updated list :  ['C++', 'Java', 'Python', 'C#']
python_lists.htm
Advertisements