Python Practice › Tuple Programs › Program 10

2nd from the front, 3rd from the back

EasyTuple Programs · 10 of 70

Write a Python program to get the 2nd element from the front and the 3rd element from the back of a tuple.

Advertisement
Input
("s", "q", "a", "t", "o", "o", "l", "s")
Output
q
o

Approach

  1. Index 1 from the front, index -3 from the back.

Solution

Python
t = ("s", "q", "a", "t", "o", "o", "l", "s")print(t[1])print(t[-3])
Output
q
o
Advertisement

Learn the concept

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

More tuple programs

← All 70 Tuple Programs