Python Practice › List Programs › Program 40

Remove elements at odd indexes

EasyList Programs · 40 of 100

Write a Python program to remove all elements at odd indexes.

Advertisement
Input
[12, 32, 33, 5, 4, 7, 33]
Output
[12, 33, 4, 33]

Approach

  1. Keep every second item starting at index 0.

Solution

Python
items = [12, 32, 33, 5, 4, 7, 33]print(items[::2])
Output
[12, 33, 4, 33]

Learn the concept

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

More list programs

← All 100 List Programs

Leave a Comment