• Register
1 vote
192 views

Problem:

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

print("Hello")
print("name")
print("hello")
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

Please log in or register to answer this question.

1 Answer

0 votes

Solution:

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!

Either

print(5 + 2)
Or
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,260 points

Related questions

0 votes
0 answers 47 views
47 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 Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 34 views
34 views
Problem: I am a newbie to the world of Python, and I am so confused about the data types in Python. I am trying to run the following program: obtained_marks = input("Enter the marks your child obtained: ") total_marks = 100 difference = total_marks - ... cannot see any evident reason for this error. I cannot identify where I am trying to subtract a string from an integer. Any helper?
asked Dec 17, 2020 Code Learner 9.8k points
0 votes
1 answer 34 views
34 views
Problem: Hello! I am new to programming and I am trying to run following code: def division(number): if(number/4 >= 1): print("Divisible by 4") else: print("Not divisible by 4") dividend = input("Enter dividend: ") division(dividend) What I am trying to do is ... 'int' I cannot see any obvious reason of this error. If any of you could identify the reason, it would be very helpful for me. Thanks!
asked Dec 17, 2020 Code Learner 9.8k points
0 votes
1 answer 5 views
5 views
Problem: How can I concentrate unsupported operand type(s) for +: 'int' and 'str' ?
asked Apr 13 sumaiya simi 43.9k points
0 votes
1 answer 83 views
83 views
Problem: typeerror: unsupported operand type(s) for +: 'nonetype' and 'str'
asked Feb 15 Ethan ross 2.7k points
1 vote
1 answer 97 views
97 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, 2020 samhaz 5k points
1 vote
1 answer 126 views
126 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, 2020 Martin K 6.6k points
0 votes
1 answer 3 views
3 views
Problem: I'm trying to get a distance calculated in mm's with a for next loop in python for fusion360. The calculation gives an error: typeerror unsupported operand type(s) for ^: 'float' and 'float' The calulation is: distance = scale - (scale / 2^ (x/12)) I think it has ... int(scale - (float(scale / 2^ (x/12)) ) But all give me the dreaded typeerror.... Who can point me in the right direction?
asked 1 day ago anika11 32k points
0 votes
1 answer 4 views
4 views
Problem: I'm trying to write an average grades calculator in Python for CodeAcademy course. I keep getting this error,TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' on the average function, total = sum(numbers). I understand that it means that I'm ... I don't understand where is this NoneType coming from, if I'm trying to sum just a list of numbers from a given dictionary?
asked 2 days ago Humaira ahmed 50.7k points
0 votes
1 answer 2 views
2 views
Problem: I wrote rock-paper-scissor game with python and I have error which I can't solve. please help. import random p1 = random.randint(0, 2) def choosing(): p = int(input("Rock: 0; Paper: 1; scissor: 2:")) if p < 0 or p > 2: print("\ ... , in <module> TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' and error comes only when I input valid value after entering invalid value
asked 2 days ago jamuna1 30.2k points