Python Part of the whole


#1

I get this error when I run my code. Oops, try again. get_class_average([alice]) resulted in an error: 'NoneType' object is not iterable. I have already searched for this problem, but nothing answers my question. And if I do fix this problem, then it goes back to saying Oops, try again. get_class_average([alice]) resulted in an error: list indices must be integers, not str. Here is my code that is having problems.

def get_class_average(student):
results =[]
for i in student:
a = get_average(student)
results = results.append(a)
results = average(results)
return results


#2

My code is actually
def get_class_average(student):
results =[]
for i in student:
a = get_average(i)
results = results.append(a)
results = average(results)
return results


#3

Hi,

give it a try without those both "results = " and call it as even after the " = "
The both list callings "results = results.append(a)" and "results = average(results)" are not necessary, imo.

Try to delete those both and if it doesn't work please post your code again :slightly_smiling:
Tip: If you want your code to be displayed correctly you can do it this way:

[c0de] at the beginning of your code (it won't be displayed, as even as for bolt or cursive letter), end your code-alignment with [/c0de] (replace 0 with o!)

Greets and fun


#4

Thank you for your help. I was able to get it working, thank to your advice.