Python solution to problem 2 added