Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

switch case dictionary python

result = {
  'a': lambda x: x * 5,
  'b': lambda x: x + 7,
  'c': lambda x: x - 2
}[value](x)
Source by simonwillison.net #
 
PREVIOUS NEXT
Tagged: #switch #case #dictionary #python
ADD COMMENT
Topic
Name
9+5 =