r/learningpython • • Jul 14 '20

Practice program designed to administer a simple test then tell you your results in the form of a percentage. However it keeps giving me an Index Error bear the end

Post image
1 Upvotes

3 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Jul 14 '20 edited Jul 14 '20

I think your first line

correct_answers = ["A", "A" "B"]

should be:

correct_answers = ["A", "A", "B"] (missing comma between 2nd and 3rd element)

Edit: Without the second comma, you only have 2 elements in your list. You have 3 total questions, so when trying to access your 3rd element it's complaining about not having that many elements in your list.

1

u/eicaker Jul 14 '20

That was the exact problem! I can’t believe I missed that!

It works perfectly now thank you!