Algorithm For Pop Operation In Python Program