def CalculateExchange(currency2,rate):
currencyamount1 = int(input("Enter the amount: "))
currencyamount2 = (currencyamount1 * rate)
print(currencyamount2,currency2)
When multiplying the exchange rate obtained earlier on in the program by the number inputted by the user, instead of it outputting an actual number, it just outputs the amount entered in the form of the exchange rate, e.g. when the exchange rate is 5 and the amount entered is 6 it will just output 6.6.6.6.6 , I could really use help, I know this problem probably seems quite insignificant and easy to correct but I'm having trouble trying to sort it out.
The easiest way to get around an error like this is to cast your int back into a float before multiplying
def CalculateExchange(currency2,rate):
currencyamount1 = int(input("Enter the amount: "))
currencyamount2 = (float(currencyamount1) * float(rate))
print(currencyamount2,currency2)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments