Dictionary as an Alternative to If-Else

Use Dictionaries to Create a Cleaner Code of If-Else Function

Khuyen Tran
Towards Data Science
4 min readFeb 14, 2020

--

Motivation

You may have been frequently working with Python’s dictionaries. But have you unlocked the full capacity of the dictionary to create a more efficient code? If you didn’t know how to create an ordered dictionary, group multiple dictionaries into a single mapping, create a read-only dictionary, you could found out more here.

--

--