Following a udemy course and I'm stuck at this " 'str object is not callable " error. I've basically copied and pasted the snippet of code giving me an issue and it still produces the same error. Haven't found anything with the exact issue I'm having but I won't be surprised if it's a comically simple fix!
The issue is with the "ops_function" bit throwing a 'str' object is not callable error.
Let me know if you need more info and thank you for any insight!
from art import logo
print(logo)
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
return a / b
operations = {
"+": "add",
"-": "subtract",
"*": "multiply",
"/": "divide"
}
first = int(input("Enter a number: "))
second = int(input("Enter another number: "))
for op in operations:
print(op)
op_choice = input("Select an operator from the list above: ")
ops_function = operations[op_choice]
answer = ops_function(first, second)
print(f"{first} {op_choice} {second} = {answer}")