slow answer 3 in python