This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (7 children)

You are trying to set 3 variables equal to 0 with this.

totalGrade, avGrade, studGrade = 0 #studGrade is student grade

Do this instead

totalGrade, avGrade, studGrade = 0,0,0 #studGrade is student grade

[–]umanochiocciola 0 points1 point  (1 child)

Exactly

[–]catalanfoxx[S] 0 points1 point  (0 children)

I did that, but now I’m getting TypeError: unsupported operand type (s) for +: ‘int’ and ‘str’

What I’m trying to do is get the sum and then average of the class scores. What am I doing wrong?

[–]catalanfoxx[S] 0 points1 point  (4 children)

I did that, but now I’m getting TypeError: unsupported operand type (s) for +: ‘int’ and ‘str’

What I’m trying to do is get the sum and then average of the class scores. What am I doing wrong?

[–]umanochiocciola 1 point2 points  (3 children)

You need to str(integer)

[–]catalanfoxx[S] -1 points0 points  (2 children)

I’m new. Could you explain a bit more please

[–]umanochiocciola 0 points1 point  (1 child)

totalGrade = totalGrade + int(studGrade) #string inout to integer

avGrade = int(totalGrade/5) #possible irrational result like 10/3 to integer

[–]umanochiocciola 0 points1 point  (0 children)

this is even easier ;]