loan_decision(income, credit_score, has_existing_debt) that returns "Approved", "Conditional", or "Rejected" for a simple loan model. If credit_score < 600, the loan is "Rejected". Otherwise, if income >= 50000 and not has_existing_debt, it is "Approved". Otherwise (credit_score >= 600 but income < 50000 or existing debt), it is "Conditional".loan_decision(60000, 700, False)
"Approved"
Good credit, high income, no debt.
loan_decision(60000, 700, True)
"Conditional"
Good credit and income but has existing debt.
loan_decision(80000, 550, False)
"Rejected"
Credit score below 600 rejects regardless of other factors.
Use a nested if inside the credit_score >= 600 branch.
The rejection guard clause should come first so you never evaluate the rest unnecessarily.