Tuesday, October 19, 2010

How to find an element in a List and return the index, Python

Check if value exist in a list, L ?
if value in L:
            print "list contains", value
Returns the index, where value exist in List, L :

i = L.index(value)




No comments: