grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
def grades_sum(grades):
sum = 0
for i in grades:
sum += grades[i]
print(grades_sum(grades))
That’s my code and I’m trying to understand why I’m getting an out of index traceback.
You don’t need to do
grade[i]because you’re already referencing the elements in the list – all you need to do it replace that with a plain oldiHowever, there is already a builtin function for this –
sum