use list.remove instead of list.pop