Does it have to return 'None'?


I was wondering if there is a way to terminate the iteration without returning the "None" string at the end.
Also I am wondering why even though I set n = 0, it goes through each list item in the for statement even though I never increment the value. I just saw that it worked out, but don't really understand why.

honor_roll_count = 0
student_grades = ["A", "C", "B", "B", "C", "A", "F", "B", "B", "B", "C", "A"]
for student_grades[n] in student_grades:
    if (student_grades[n] == "A" or student_grades[n] == "B"):
        honor_roll_count +=1


Hmm.. So I realise n=0 is redundant.
I thought I was giving a value to the n in student_grades[n], but I realise that 'student_grades[n]' is a variable itself.

But is it still possible to not return a "None"?


the None is just caused by the codecademy console, go run it in a python IDLE and you won't see None, don't worry about it


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.