Python-tuple
Python-tuple
Tuples in Python
Tuples are used to store multiple items in a single variable.
A tuple is a collection which is ordered and unchangeable.
Tuples are written with round brackets.
One cannot add items to a tuple once it is created.
Tuples cannot be appended or extended.
We cannot remove items from a tuple once it is created.
Create Tuple With One Item
To create a tuple with only one item, you have to add a comma
after the item, otherwise Python will not recognize it as a tuple
Indexing in Python Tuple
Method Description
count() Returns the number of times a specified value occurs in
a tuple
index() Searches the tuple for a specified value and returns the
position of where it was found
Len() of Tuple
To determine how many items a tuple has, use the len() function
Example:-