Skip to content
Advertisement

converting a text in a dictionary

i have a text file like this and i am converting the text file into a dictionary. making one of the values the key and the rest the values within the key.

JavaScript

and this is what i have cuz one of the student is missing a grade on purpose.

JavaScript

my problem is when i try to run it,the output keeps saying that grade = line[6] is out of range. can someone help? Thank you

Advertisement

Answer

Check the length of line before trying to use line[6]

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement