Are you in the same course as monkeybut?
I believe the problem is that the line 45 should be within the for-loop.
I also posted a solution on the thread by monkeybut, but I wouldn't suggest submitting that for your assignment, the prof will be very suspicious if you do.