Problem 41 (python): solved