I would suggest adding some print statements to your gradingTool function... Print each argument (with delimiters so you can see where they end), and then inside your loop, print i, studentAnswers[i] and correctAnswers[i]. I suspect this may reveal the issue...