Revolut interview question

To create a Python function related to the problem that they will show you.