LOOKUP function in python


i’m kinda new to Python and i’m trying to create my very first program. I decided to make something like FX values (for example EUR/USD). So I created a list, e.g. FX_list = ("12/31/2022", 1.0666). Index [0] is representing date of FX rate, floating number[1] is it’s value. My question is, if i can make a function, where i input the string which represents date and in return i get the index 1? It is supposed to work like "vlookup" or "xlookup" in Excel. Thanks for help 🙂

As i typed above, i’m expecting that the function will lookup the date from list and in return i get the value. List = (x,y) .. lookup x, return y

Asked By: Filip Dolezal



Try dictionary.

FX_list = {"12/31/2022" : 1.0666}

And then


or loop through

Answered By: furfant
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.