Affirm interview question

Scenario based question and solved using python