check if index is last in list python