0% found this document useful (0 votes)
36 views3 pages

06 Python Tuple Methods

Tuple methods allow searching for values in a tuple and returning the count or index of matches, with count() returning the number of matches and index() returning the index of the first match or raising an exception if not found.

Uploaded by

Thohith Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

06 Python Tuple Methods

Tuple methods allow searching for values in a tuple and returning the count or index of matches, with count() returning the number of matches and index() returning the index of the first match or raising an exception if not found.

Uploaded by

Thohith Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Tuple Methods

count()
Returns the number of times a specified
value appears in the tuple.

Returns 0 if the value is not found.

Syntax – tuple.count(value)

Parameters:
value – Required – Any Data Type
The item to search for.
index()
Searches the tuple for a specified value and
returns the index of where it was found.

Raises an exception if the value is not found.

Syntax – tuple.index(value)

Parameters:
value – Required – Any Data Type
The item to search for

You might also like