2

I am trying to make it so say if the two strings are "Danny" and "DeVito" And if you do something, like if you search for "Danny" then it will return "Danny" and "DeVito" and vise-versa. I thought about dictionaries, but I'm not sure how to use those.

EDIT: Extra info

I was also wondering if there was a way to search in all of the pairs and see if a string is in it. Hope this makes sense.

EchoTheAlpha
  • 422
  • 2
  • 8
  • 27

1 Answers1

1

Python has a great module for this called bidict

https://bidict.readthedocs.io/en/latest/basic-usage.html

>>> element_by_symbol = bidict(H='hydrogen')
>>> element_by_symbol.inverse['helium'] = 'He'
>>> del element_by_symbol.inverse['hydrogen']
>>> element_by_symbol
bidict({'He': 'helium'})

(Example code from https://bidict.readthedocs.io/en/latest/basic-usage.html)

Aayush Agrawal
  • 1,354
  • 1
  • 12
  • 24