RosettaCodeData/Task/Conditional-structures/Python/conditional-structures-6.py
2023-07-01 13:44:08 -04:00

8 lines
131 B
Python

# The above, but with a dict literal
dispatcher = {
0: foo,
1: bar,
2: baz,
}
# ...
results = dispatcher.get(x, boz)()