Problem 1 in python