0

I have a program that takes some string as a input. However, that same string can be written in many equivalent ways. Tinkering with Python dictionaries, I found out that making some dictionary like

things = {
"a1" : "a",
"a2" : "a",
}

works out for what I want to do (which is iterating through an excel column and getting the adjacent value for "a" by inputting either "a1" or "a2"), but I was wondering is there's a better way to do this, since this will be super expensive whenever I'll decide to add more entries to the dictionary.

Impasse
  • 85
  • 9
  • [Related](https://stackoverflow.com/questions/513882/python-list-vs-dict-for-look-up-table) – Olvin Roght Jun 10 '20 at 12:05
  • Why do you think it would be expensive (I assume you mean CPU time with that?)? – Michael Butscher Jun 10 '20 at 12:05
  • To be fair I'm not 100% sure about that since I'm just starting out with Python, but I'd assume that iterating through a dictionary and comparing strings is not really fast. But I also think I can easily be wrong since I'm not even sure how that happens in that case in particular. – Impasse Jun 10 '20 at 12:20

0 Answers0