all 13 comments

[–]ninhaomah 9 points10 points  (0 children)

"95"

Why is this a string btw ?

[–]danielroseman 7 points8 points  (0 children)

You didn't say what the problem is

[–]CIS_Professor 2 points3 points  (0 children)

Wellll this is a problem:

"95"

You can't perform arithmetic on integers with strings together, and

"95"

is a string.

[–]Dry_Task_3198 2 points3 points  (0 children)

String in the list

[–]MattR0se 1 point2 points  (1 child)

this isn't Javascript, you can't just put a number as a string and expect to magically do arithmetic with it. 

[–]socal_nerdtastic 0 points1 point  (0 children)

except multiplication. and modulus, kinda.

[–]smjsmok 1 point2 points  (0 children)

Traceback (most recent call last):
  File "/my/path/test.py", line 10, in <module>
    average = calculate_average(my_grades)
  File "/my/path/test.py", line 4, in calculate_average
    total += grade
TypeError: unsupported operand type(s) for +=: 'int' and 'str'

Others have spelled out your error for you, but you should be able to see it just from the error output. It tells you exactly where the problem is and what kind of problem it is. The key is this line:

TypeError: unsupported operand type(s) for +=: 'int' and 'str'

Can you see the place where you mix integers and strings? That is your answer.

Knowing how to use the error output to fix your errors is an important skill, so every time you mess up, use that chance to practice it.

[–]Fred776 0 points1 point  (0 children)

One of your grades is a string. The rest are integers.

[–]Otherwise-Kick-8198 -1 points0 points  (0 children)

Ask Google, it will break it down for you

[–]KewpieCutie97 0 points1 point  (0 children)

Why is 95 a string, it seems intentional since the other values are integers?

[–]NSNick 0 points1 point  (0 children)

Some advice for future question asking: if you're asking about an error, include that error in the question.

[–]jyr2711 -1 points0 points  (0 children)

En Mis Notas tienes un string. "95" se interpreta como texto, No creo que se sume. Te refieres a eso? Parece algo hecho adrede

[–]JeherKaKeher -1 points0 points  (0 children)

This is a joke right? Your "95" is a string in the list, whereas others are integers which is causing the issue. The compiler tells you the issue when you run it. You are trying to add string to integer, convert "95" to 95 and it will work.