In this python tuple program, we will slice a tuple.
Steps to solve the program
- Create a tuple.
- Slice the given tuple using tuple_name[start_index:end_index].
- Print the output.
tup = (5,7,3,4,9,0,2)
print("Original tuple: ",tup)
print(tup[:3])
print(tup[2:5])
Output :
Original tuple: (5, 7, 3, 4, 9, 0, 2)
(5, 7, 3)
(3, 4, 9)