prob2 python code