I have some code where I am using a list of names, and a file (eventually multiple files) of results (team, name, place). The end result I am looking for is to have each person
By using Scores=dict.fromkeys(lines,[])
you're initializing every key of the dict with a reference to the same list, so changes made to the list are reflected across all keys. You can use a dict comprehension for initialization instead:
Scores = {line: [] for line in lines}
Alternatively, you can initialize Scores
as a normal dict {}
and use the dict.setdefault
method to initialize its keys with lists:
Scores.setdefault(a[1], []).append(score)