PythonListinsert

Inserts an item at a given position.

Syntax

list.insert(i, item)

Example

Enter values below to update the example in real time.

nums
print
nums = [1, 2, 4, 5]
nums.insert(2, 3)
print(nums)  # [1, 2, 3, 4, 5]