Python Tutorial

Python Tuple Slicing Explained With Examples

How to Slice Tuples in Python?

You must use the [] operator on a tuple to index or slice it. If you supply a positive integer while indexing a tuple, it pulls that index from the tuple counting from the left. If the index is negative, it is retrieved from the tuple counting from the right.

Python Tuple Slicing Example:

my_tuple = ('a', 'b', 'c', 'd')

print(my_tuple[1])

print(my_tuple[-1])

Output:

b
d
Did you find this article helpful?