I’m a newbie to Python, started learning it a few days ago. Apparently, I couldn’t add two objects with each other and I was confused because it didn’t make sense to me, it felt like reading gibberish. Attaching code below:
add = input('Enter value: ') print(add + 1)
The code works fine, it takes my input but when I try to make the input value to be added by 1, it throws this gibberish error, attaching code:
Traceback (most recent call last): File "test.py", line 2, in <module> print(add + 1) TypeError: can only concatenate str (not "int") to str
It throws a
TypeError and I read about it online that it only occurs when the operation’s datatype isn’t compatible. Can anyone tell me if there’s a way or a function using which I can check my datatypes for the object I create so that I can check where the problem lies and fix it?