Problem2 in Python