Python Practice › List Programs › Program 57

Insert an item at an index

EasyList Programs · 57 of 100

Write a Python program to insert an item at a specific position.

Advertisement
Input
[2, 4, 6, 8, 3, 22], index 3, item 55
Output
[2, 4, 6, 55, 8, 3, 22]

Approach

  1. insert(index, item).

Solution

Python
items = [2, 4, 6, 8, 3, 22]items.insert(3, 55)print(items)
Output
[2, 4, 6, 55, 8, 3, 22]

Learn the concept

New to this topic? Read the lesson, then come back.

More list programs

← All 100 List Programs

Leave a Comment