Python Practice › String Programs › Program 30

Characters at even indexes

EasyString Programs · 30 of 106

Write a Python program to print the characters at even index positions (0, 2, 4, …).

Advertisement
Input
"sqatools"
Output
saol

Approach

  1. Slice with a step of 2.

Solution

Python
print("sqatools"[::2])
Output
saol

Line by line

Line 1

Starting at 0 with step 2 takes indexes 0, 2, 4 and 6.

Advertisement

Learn the concept

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

More string programs

← All 106 String Programs