Nested If Decision Tree: Loan Eligibility

Medium ⏱ 12 min 51% acceptance ★★★★☆ 4.4
Write a function 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".

Examples

Example 1
Input
loan_decision(60000, 700, False)
Output
"Approved"
Explanation

Good credit, high income, no debt.

Example 2
Input
loan_decision(60000, 700, True)
Output
"Conditional"
Explanation

Good credit and income but has existing debt.

Example 3
Input
loan_decision(80000, 550, False)
Output
"Rejected"
Explanation

Credit score below 600 rejects regardless of other factors.

Constraints

  • income is a non-negative number.
  • credit_score is an integer.
  • has_existing_debt is a boolean.

Topics

Conditional Statementsnested conditionalsBusiness Logic

Companies

Goldman SachsDeutsche BankJPMorgan Chase

Hints

Hint 1

Use a nested if inside the credit_score >= 600 branch.

Hint 2

The rejection guard clause should come first so you never evaluate the rest unnecessarily.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.