learn code with examples

Python Tuple


# Example, Python tuple looks like...
gender = ( 'female', 'male', 'prefer not to share')
car_available = ( 'Ford', '1200cc', 'auto', 21243 , 2009)

Tuple used to store more than one element. In Python, tuple is written with round brackets ( ) - (i.e. parentheses). Elements are separated by comma , character. Tuple can hold different data types in same tuple. Tuple can have duplicate items.

Tuple Vs List


Tuple is immutable. It means, you can not modify its content once it is created. List is mutable and its content can be modified (add/remove/update).


Both are sequence data types. So, they can be used to store multiple elements together. Elements accessed by index.


  • class 'tuple'

Working with Tuple

You can check in details about Creating Tuple. Generally, what is Default Value for Tuple variable, Memory requirement for Tuple, How to find length of Tuple.

Tuple Index and Tuple Slice are described in details. Tuple supports various operations like: Find occurrences of element in Tuple (or Find if element is present or not), Find index of element.

Since Tuple is immutable, following operations can be done using workaround: Replace element, Append at end, Extend at end, Insert at start/front, in middle, at end, Remove element by Value, Remove element by Index, Remove All.

In this page...

Copyright © All rights reserved.