Python Practice › String Programs › Program 34

Characters at odd indexes

EasyString Programs · 34 of 106

Write a Python program to print the characters at odd index positions.

Advertisement
Input
"abcdefg"
Output
bdf

Approach

  1. Slice from index 1 with a step of 2.

Solution

Python
print("abcdefg"[1::2])
Output
bdf

Learn the concept

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

More string programs

← All 106 String Programs

Leave a Comment