Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python List insert() Method


previous next AddThis Social Bookmark Button


Description:

This method inserts object obj into list at offset index.

Syntax:

list.insert(index, obj)

Parameters:

Here is the detail of parameters:

  • index: Index where the object obj need to be inserted.

  • obj: Object to be inserted into the given list

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 Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names