We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Purchase Bug

There's a bug in the merchant system that allows players to buy items from the shop even when they don't have enough gold.

Assignment

Complete the purchase_item function.

  1. If the character doesn't have enough gold raise an Exception with the text not enough gold.
  2. Otherwise, return the amount of remaining money the customer has after completing the purchase.

Do not handle the exception, the test file does that for you.