Finding the index of a string in a tuple
Question:
Tup = ('string1','string2','string3')
My program returned string2 how do I get it’s index within Tup?
Answers:
>>> tup.index('string2')
1
Note that the index()
method has only just been added for tuples in versions 2.6 and better.
Tup = ('string1','string2','string3')
My program returned string2 how do I get it’s index within Tup?
>>> tup.index('string2')
1
Note that the index()
method has only just been added for tuples in versions 2.6 and better.