Answer the question
In order to leave comments, you need to log in
How to fix TypeError: unsupported operand type(s) for -: 'str' and 'str'?
Hello. I am new and just learning python. I tried to make a calculator and got such an error when trying to count on -
Maybe someone knows how to solve this?
Here is the code:
what = input ("Select an action (+ or -):")
a = input("Enter the first number: ")
b = input("Enter the second number: ")
if what == "+":
c = a + b
print("Result: " + c)
elif what == "-":
c = a - b
print("Result: " + c)
else:
print("Invalid operation!")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question