Python Practice › List Programs › Program 73

Every other item

EasyList Programs · 73 of 100

Write a Python program to create a list from every second item.

Advertisement
Input
[3, 5, 7, 8, 2, 9, 3, 5, 11]
Output
[3, 7, 2, 3, 11]

Approach

  1. [::2].

Solution

Python
print([3, 5, 7, 8, 2, 9, 3, 5, 11][::2])
Output
[3, 7, 2, 3, 11]
Advertisement

Learn the concept

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

More list programs

← All 100 List Programs