IBM interview question

Solve the following Python question?