Python Practice › String Programs › Program 34
Characters at odd indexes
Write a Python program to print the characters at odd index positions.
Input
"abcdefg"
Output
bdf
Approach
- Slice from index 1 with a step of 2.
Solution
print("abcdefg"[1::2])Output
bdf
Learn the concept
New to this topic? Read the lesson, then come back.