tags:

views:

46

answers:

1
Tup = ('string1','string2','string3')

My program returned string2 how do I get it's index within Tup?

+5  A: 
>>> tup.index('string2')
1

Note that the index() method has only just been added for tuples in versions 2.6 and better.

Adam Bernier
@Jerub: thanks for the edit. I had nearly simultaneously added more info so I rolled back your edit. Cheers.
Adam Bernier
Thanks, I'm running 2.6 so it wasn't an issue.
Anteater7171