problem 2, done in python