Python 2.7
'count' is a list.
Values...
len(count): 216
count[26]: '20'
count.index('20'): 142
count[142]: 167
I thought count.index('20') should find the value of '20' in the list and return the index of '26'. What am I missing?
1
Expert's answer
2012-08-14T09:36:30-0400
count.index(x) return the index in the list of the first item whose value is x. It is an error if there is no such item. Probably, the value of the 26th element was 20, but not '20'.
Comments
Leave a comment