Python Practice › Tuple Programs › Program 10
2nd from the front, 3rd from the back
Write a Python program to get the 2nd element from the front and the 3rd element from the back of a tuple.
Input
("s", "q", "a", "t", "o", "o", "l", "s")Output
q o
Approach
- Index 1 from the front, index -3 from the back.
Solution
t = ("s", "q", "a", "t", "o", "o", "l", "s")print(t[1])print(t[-3])Output
q o
Learn the concept
New to this topic? Read the lesson, then come back.