Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Python – Insert Element to List – insert() Function with Examples

insert() function is used to Insert an item at a given position in Python programming language.

Syntax of insert() Function

The syntax of insert() function in Python is:


Parameters of insert() Function in Python

i – Where i is any place where he item needed to be inserted. This parameter is required.
x – Where x is the item that is going to insert. This parameter is required.



insert() function is available and compatible with both Python 2.x and 3.x. This function is one of python list methods.


Return Value of insert() Function in Python

insert() function doesn’t return any value.


Python insert() Function Example 1

['gray', 'green', 'red', 'orange', 'pink']


Python insert() Function Example 2

[{'green', 'gray'}, ('red', 'silver'), ['orange', 'pink', 'yellow', 'white']]

LearnAndLearn.com © 2018 - All rights reserved