Problem 30 (python): solved