Write a Python program to find the index of an item of a tuple.
tuplex = tuple("index tuple") print(tuplex) index = tuplex.index("p") print(index) index = tuplex.index("p", 5) print(index) index = tuplex.index("e", 3, 6) print(index) index = tuplex.index("y")
('i', 'n', 'd', 'e', 'x', ' ', 't', 'u', 'p', 'l', 'e') 8 8 3 Traceback (most recent call last): File "d0e5ee40-30ab-11e7-a6a0-0b37d4d0b2c6.py", line 14, in <module> index = tuplex.index("y") ValueError: tuple.index(x): x not in tuple
Write a Python program to find the index of an item of a tuple
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.