Im trying to find out the number of where X is in the list e.g:
if i had a list like: ['a','b','c','d']
and i have 'c' how would i find where it is in the list, so that it would print '2' (as thats where it is in the list)
thanks
Asked
Active
Viewed 30 times
0

Jared Parker
- 390
- 2
- 3
- 16
-
2Possible duplicate of [How to get item's position in a list?](http://stackoverflow.com/questions/364621/how-to-get-items-position-in-a-list) – Damaged Organic Sep 11 '16 at 13:38
1 Answers
1
Use the built-in method list.index
If you wanna know where is 'c':
l = ['a','b','c']
l.index('c')

Alvaro Marques
- 80
- 4
-
If Marques provided an answer that is actually a solution to your problem, you should mark his answer as solution. – MaxPowers Sep 19 '16 at 16:05