Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try dictionary.

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

And then

FX_list.get("12/31/2022")

or loop through

FX_list.keys
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading