RosettaCodeData/Task/Conditional-structures/Python/conditional-structures-6.py

9 lines
131 B
Python

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