python test if index exists in list