1. Learn
  2. /
  3. Projects
  4. /
  5. Case Study: Building Software in Python

Connected

Exercise

Refactor Code

You decide to refactor the code after the code review using best practices in software engineering. For instance, the number of total payment should not be less than zero. Throw an error if this situation happens.

Instructions

100 XP
  • Fill in the error condition with the variable representing the total number of months of the loan.
  • Throw a ValueError if the number of monthly payments is less than zero.
  • Return the loan amount.