I recently started a beginners programming course and am struggling with my latest assignment. I have been given a .txt file of the results of a relay race with the following columns of data:
team
leg
runner
time
It is my job to write a code which reads this file and outputs a list of the teams with their total times. I have had no issues importing the file, but I am completely lost on how to link team names (which are not specified) with the times of each runner (3 to a team) - let alone how to get the total 3 times from seconds to hh:mm:ss
I know that this can be solved with a dictionary but can't find anything on dictionaries and file input that seems to help. I assumed a simpler method would be to have two seperate lists or a list within a list such as
TIME = [[N1, T1], [N2, T2]....]
but I simply get an error code saying the above names are not defined when I try the list within a list method.
If anyone can see what the massive gap in my knowledge is then I would be extremely grateful, this one really has me stummped and I'm starting to get quite aggitated!
team
leg
runner
time
It is my job to write a code which reads this file and outputs a list of the teams with their total times. I have had no issues importing the file, but I am completely lost on how to link team names (which are not specified) with the times of each runner (3 to a team) - let alone how to get the total 3 times from seconds to hh:mm:ss
I know that this can be solved with a dictionary but can't find anything on dictionaries and file input that seems to help. I assumed a simpler method would be to have two seperate lists or a list within a list such as
TIME = [[N1, T1], [N2, T2]....]
but I simply get an error code saying the above names are not defined when I try the list within a list method.
If anyone can see what the massive gap in my knowledge is then I would be extremely grateful, this one really has me stummped and I'm starting to get quite aggitated!
Comment