How to Use List append() Method in PythonPython Basics


The append() method is used to add a new object at the end of the list.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

list1 = ['MIT', 'CIT', 'Yale','UCI']
list1.append('NYU')
print ("The new list is: ", list1)

Output:

The new list is:  ['MIT', 'CIT', 'Yale', 'UCI', 'NYU']

Syntax

list.append(obj)

Parameters

Name Description
obj Object added to the end of the list.

Return Value

It doesn’t return any value.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us