Currency Exchange exercise, instruction 6

Hi, guys!

I’m stuck in this exercise. I have made a solution that is returning the right answer (apparently) but, in the test, the return is completly different. can someone help me, please?
Here is my code:

def exchangeable_value(budget, exchange_rate, spread, denomination):

    :param budget: float - the amount of your money you are planning to exchange.
    :param exchange_rate: float - the unit value of the foreign currency.
    :param spread: int - percentage that is taken as an exchange fee.
    :param denomination: int - the value of a single bill.
    :return: int - maximum value you can get.
    final_rate = exchange_rate + (spread / 100)
    final_budget = budget / final_rate
    final_value = final_budget - (final_budget % denomination)
    return int(final_value)
1 Like

The problem is this line:

final_rate = exchange_rate + (spread / 100)

The instructions explain:

Parameter spread is the percentage taken as an exchange fee, written as an integer. It needs to be converted to decimal by dividing it by 100. If 1.00 EUR == 1.20 USD and the spread is 10, the actual exchange rate will be: 1.00 EUR == 1.32 USD because 10% of 1.20 is 0.12, and this additional fee is added to the exchange.

Simply adding spread / 100 to the exchange_rate does not work. You can see that in the example above: Calculating exchange_rate + (spread / 100) gives you 1.20 + (10 / 100) == 1.30, not the correct 1.32.

Remember: The spread is in percent and it’s basically a factor for the exchange rate.

Let me know if you need another hint or some more substantial help. Cheers!

1 Like

Thank you very much :slight_smile: