r/PythonLearning • u/gyrojoestar31 • Sep 17 '26
Help Request any clue how to do this?
im on my first year of learning python in school is this even possible??
25
Upvotes
r/PythonLearning • u/gyrojoestar31 • Sep 17 '26
im on my first year of learning python in school is this even possible??
View all comments
6
u/AQuestionIsWhatIHave Sep 17 '26
Use a dict to map a symbol onto an operator function.
op = input('Operation...').trim()
opDict = {'+' : lambda x,y: print('Result:' x+y) l, ...}
opFoo = opDict.get(op, lambda x, y: print('Invalid operator'))
opFoo(inputA, inputB)