Hacker Rank Python Functions Solution