Question: The file format inindex.txtis an unusual one. It has three fields --- name, scores, and ID --- that are comma separated but the scores column
The file format inindex.txtis an unusual one. It has three fields --- name, scores, and ID --- that are comma separated but the scores column consists of "bar" (i.e.,|) separated scores. Furthermore, some scores in that column are missing.
Write some code that reads in the filegrades.txtand calculates the total of the scores that are present. Any missing scores should be treated as having the value zero. So, for example, if the score column is10||20|30then the total should be 60.
Your code should print out the results for each line ingrades.txton its own line in the formName:Total, whereNameis the name in the first column andTotalis the integer sum of the scores.
Contents ofgrades.txt
Mark,20|25|15|40,u4466898
Sue,45|12|30|15,u1234567
Jane,50|30||35,u3425174
Bob,20||20|20,u48539482
CODE:
# TODO: Implement your code here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
