Problem #2 using python