OpenAI Interview Question

Refactor the following simple code