Computer Science
How are in operator and index( ) similar or different ?
Python Tuples
3 Likes
Answer
Similarity:
in operator and index( ) both search for a value in tuple.
Difference:
in operator returns true if element exists in a tuple otherwise returns false. While index( ) function returns the index of an existing element of the tuple. If the given element does not exist in tuple, then index( ) function raises an error.
Answered By
3 Likes