d = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x *
    y, '/': lambda x, y: x / y}
try:
    print(d[op](part1, part3))
except KeyError:
    pass
Using a dictionary as a switch statement in Python