'Invalid Decimal Literal on Currency Conversion Script [closed]

Had a general question regarding Invalid Decimal Literal.

I've created a basic currency conversion script for ad spends on pivot tables that use USD and I'm converting it to GBP.

I've gone over the script and have tried to optimise by using online resources and using Stack Overflow. I've experimented with several solutions but I can't seem to figure out nor understand why it's happening and how to apply best practice from making ridiculous mistakes.

I've attached the code below for your review:

import requests
  
class Currency_convertor:
    # empty dict to store the conversion rates
    rates = {} 
    def __init__(self, url):
        data = requests.get(url).json()
  
        # Extracting only the rates from the json data
        self.rates = data["rates"] 
  

    # function to do a simple cross multiplication between 
    # the amount and the conversion rates
    def convert(self, from_currency, to_currency, amount):
        initial_amount = amount
        if from_currency != 'EUR' :
            amount = amount / self.rates[from_currency]
  
        # limiting the precision to 2 decimal places
        amount = round(amount * self.rates[to_currency], 2)
        print('{} {} = {} {}'.format(initial_amount, from_currency, amount, to_currency))
  
***# Driver code
if __name__ == "__main__":
    url = str.__add__('http://data.fixer.io/api/latest?access_key=', 95e8617f265030569da10ad979de7ed4)**  
    c = Currency_convertor(url)
    from_country = input("From Country: ")
    to_country = input("TO Country: ")
    amount = int(input("Amount: ")))*
  
    c.convert(from_country, to_country, amount)

Any advice would be helpful.

Thank you in advance.

It's been mentioned in the comments that I wasn't clear the part of the Driver code were it's causing a Syntax Error with Invalid Decimal Literal has been fixed but it has been replaced with another error: TypeError: expected 1 argument, got 0.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source