Grab interview question

Solve a question using Python.