TypeError: unsupported operand type(s) for -: 'str' and 'str'
I am trying to do a simple subtraction program.
a = input()
b = input()
print(a-b)
But its throwing me an error unsupported operand type(s) for -: 'str' and 'str'
how to fix?
1 Answer
4 years ago by Divya
By default, the input method reads the values as strings, to fix that you need to typecast
a = input()
b = input()
print(int(a)-int(b))
4 years ago by Divya