python check if index exists in list