What is the use in python insert

description

insert () function is used to specify the object into the specified position in the list.

grammar

insert () method syntax:

list.insert(index, obj)

  

parameter

index - the index object obj to be inserted position.

obj - object to be inserted in the list.

return value

This method does not return a value, but will insert the location specified object in the list.

Examples

The following examples illustrate the insert () function using the method:

#!/usr/bin/python
aList = [123, 'xyz', 'zara', 'abc']
aList.insert( 3, 2009) 
print "Final List : ", aList

  Examples of the above output results are as follows:

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

  

Guess you like

Origin www.cnblogs.com/daniumiqi/p/12155975.html