Search code examples
pythonpython-3.xlistfunctionforex

Fomatting from a list to a function in python


Disclaimer: Beginner

I have a list of currency pairs like below:

  pair_list = ["AUD/CAD","CAD/SEK","CHF/DKK"]

I am trying to map each pair to a function like below:

AUD_CAD, metadata_AUD_CAD = fx.get_currency_exchange_daily(from_symbol='AUD',to_symbol='CAD', outputsize="full")

I've tried a few solutions to get this to work but no success so far, I know the solution is simple but I've not found it yet. In the meantime, does anyone know how I would go about getting this?


Solution

  • result = {}
    for pair in pair_list:
        (from, to) = pair.split('/')
        result[pair] = fx.get_currency_exchange_daily(from_symbol=from, to_symbol=to, outputsize="full")