A solution for 5th Python homework