Python index() method throws an error if the item was not found. So instead you can make it similar to the indexOf() function of JavaScript which returns -1 if the item was not found:
def indexof( array, elem): try: return array.index(elem) except ValueError: return -1