[SOLVED] 4/9; Is this a bug?


#1

grades = [100, 100, 90, 4080, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
total = 0
for item in scores:
total += int(item)
return total

print grades_sum(grades)

This code returns the error "Oops, try again. Make sure to print the result of the grades_sum() function." However, the result window even shows 1045 and I'm doing everything the problem is asking for. What am I doing wrong?


#2

It's not a bug.

The correct answer is 1045.5.

Why do you cast all numbers to integers before adding them to the sum?


#3

Oh, whoops. I feel dumb. My bad.


#4

No need to feel dumb! Mistakes are an integral part of programming :smile: