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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started