Q. How are in operator and index() similar or different?

 

Answer =

 

Similarity:-

 

in operator and index() both are similar because they tells existence of element in tuple.

 

Difference:-

 

 in operator return true if element exist in a tuple otherwise return false. While index() function returns the index of an existing element of the tuple. But if the given items does not exist in tuple, then it raise error.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post