• Register
1 vote


Hi all
This is a question from a noob who started coding a few hours back.

print("Let's do some math!")
print(5 + "a")
print("5 + 5")
print("Thanks for playing along!")

It says, “typeerror: unsupported operand type(s) for +: 'int' and 'str'” What does it mean?

12 7 7
15,250 points

1 Answer

0 votes


Hello Pal,

The problem happened when you write 

print(5 + "a")

You’ve messed up with two different data-types. Python can’t add them together in a single print function. You can either change them both to numbers or change them both to strings. Your choice!


print(5 + 2)
print("5" + "a")

In the first example, we are printing the result of adding two integers. In the second example, we are printing the result of concatenating two strings.

Hope this helps! :sparkles:

13 9 6
94,240 points

Related questions

0 votes
0 answers 2 views
Using pip install for any module apparently on my Ubuntu 16.04 system with python 2.7.11+ throws this error: TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' What is wrong with pip? How could I reinstall it, if necessary? Update: Full traceback is below ... File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 228, in increment total -= 1
asked 7 hours ago psandprop 800 points
1 vote
1 answer 49 views
Problem: I wrote the following program in python and it throws me the error message: Please enter your first number: 10 Please enter your secoend number: 5 Addition of your numbers 105 Traceback (most recent call last): File "ires.py", line 9, in <module> ... some wong output and then it throws the error message. Is there any problem in my program thats causing this error? Thanks in advance.
asked May 12 samhaz 5k points
1 vote
1 answer 56 views
Problem : I am a student and I am trying to learn python. I like programming so trying my hand on Python but the code which I have written in Python is giving me very strange looking error shown as below for your reference. Error: unsupported operand type(s) for ... array1=[1,2,3,4,5]; encryptedArray=runEncrypt(array1,4); print(encryptedArray); Please guide me in fixing my above error in Python.
asked May 15 Martin K 6.6k points
1 vote
1 answer 28 views
Problem : I want to learn the python programming and also want to work on projects. One of my projects is to code the voting system so that it can select the best player among 23 players of a match by using the lists. I am currently using the Python3. Please ... any of the strings in my above code all my variables are of the type integers. Please guide me in fixing above python related error.
asked May 14 Martin K 6.6k points
1 vote
1 answer 27 views
Problem: For the following python program et some error messages. The code: def Yanwa(Array,a): n = len(Array) for column in xrange(n-1): for row in xrange(column+1, n): xmult = Array[row][column] / Array[column][column] Array[row][column] = xmult for col in ... not defined Typeerror: unsupported operand type(s) for -: 'list' and 'list' Can any one sort this problem and help me out to solve this?
asked Apr 27 samhaz 5k points