Problem 118 (python): solved