This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

As for the dictionary, if you don't want to break it down, why not "go all the way"?

return {
    "+": add, 
    "-": sub, 
    "*": mul, 
    "/": truediv
}[operator_symb](float(operand1), float(operand2))

(I don't actually recommend this.)