Copyright © tutorialspoint.com

Python List insert() Method

previous next


Description:

This method inserts object obj into list at offset index.

Syntax:

list.insert(index, obj)

Parameters:

Here is the detail of parameters:

Return Value:

It returns none but it inserts the given element at the given index.

Example:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc'];

print "Final List : ", aList.insert( 3, 2009);

This will produce following result:

Final List : [123, 'xyz', 'zara', 2009, 'abc']

previous next

Copyright © tutorialspoint.com