Python Practice › String Programs › Program 30
Characters at even indexes
Write a Python program to print the characters at even index positions (0, 2, 4, …).
Input
"sqatools"
Output
saol
Approach
- Slice with a step of 2.
Solution
print("sqatools"[::2])Output
saol
Line by line
Line 1
Starting at 0 with step 2 takes indexes 0, 2, 4 and 6.
Learn the concept
New to this topic? Read the lesson, then come back.