Quote:
|
Originally Posted by DaWei
 What does that mean? Replace the arithmetic operator with a function?
|
He probably means something like:
from operator import add, sub, mul, div
operators = { '+' : add, '-' : sub, '*' : mul, '/' : div }
op = raw_input("Please enter the prefered operator: +, -, *, /")
a = int(raw_input("Please enter a number:"))
b = int(raw_input("Please enter another number:"))
print "Answer = " + operators[op](a, b)