I want to use arithmetic operations in python from given tuple. Thing is i know i can use if statements for each of them and depending on user input it will give the correct answer. I don't know but is there a way to do it without ifs. I've tried with for as you can see below but I'm having trouble getting the string as an arithmetic operator.
Code:
__operators = ('+', '-', '/', '//', '*', '**', '%')
def calculator():
x = input()
operator = input()
y = input()
op = operator
# print(str(x) + operator + str(y))
rezultat = 0
for operator in __operators:
if operator in __operators:
operator = op
rezultat = x + op + y
print(rezultat)
return rezultat
calculator()