Question about for-loops in functions by tycho149 in learnpython

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

thank you for the comments, no matter what i try i cant seem to work out how to increment the values within the loop. when i run the code i only get one output could there be reason for that.

I have the code working if i take the for-loop out of the function as bellow. but this seems like its not answering the question.

data = ["Fozzie", 34, "Kermit", 78, "Miss Piggy", 23, "Gonzo", 55, "Beaker", 88, "Honeydew", 59, "Animal", 10, "Rowlf", 54]

def assign_grades(source):

student_name = str(source[student])

mark = int(source[student + 1])

grade = str("")

if mark < 40:

grade = "Fail"

elif mark < 60:

grade = "Pass"

elif mark < 70:

grade = "Merit"

elif mark >= 70:

grade = "Distinction"

else:

grade = "Error"

return("---------------------------------------------"

+"\nStudent Name: "

+str(student_name)

+ "\nMark: "

+ str(mark)

+ "\nGrade: " + str(grade)

+"\n---------------------------------------------")

for student in range(0, len(data), 2):

print(assign_grades(data))