Solved first problem in Python