Dictionaries are mainly used as a data structure in Python for maintaining key-value pairs.
However, there's another special use case that dictionaries can handle. This is — Eliminating IF conditions from your code.
Consider the code snippet above. Here, corresponding to an input value, we invoke a specific function. The traditional way requires you to hard-code every case.
But with a dictionary, you can directly retrieve the corresponding function by providing it with the key. This makes your code concise and elegant.
Share this post on LinkedIn: Post Link.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.
Nice bhaiya😍