@RussAbbott/

RelevantLikableConditional

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def dispatch_dict(operator, x, y):
    return {
        'add': lambda a, b: a + b,
        'sub': lambda a, b: a - b,
        'mul': lambda a, b: a * b,
        'div': lambda a, b: a / b,
    }.get(operator, lambda: None)(x, y)


print(dispatch_dict("add", 7, 9)) 
print(dispatch_dict("sub", 7, 9)) 
print(dispatch_dict("mul", 7, 9)) 
print(dispatch_dict("div", 7, 9))