Question: File Handling The file format inindex.txtis an unusual one. It has three fields --- name, scores, and ID --- that are comma separated but the

File Handling

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 is'10||20|30'then the total should be 60.

Your code should print out the results for each line in'grades.txt'on its own line in the form'Name:Tota'l, where'Name'is the name in the first column and'Tota'lis 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

# TODO: Implement your code here (Python):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!