The dictionary should have player names for the keys. The value for each key must be a two-element list holding the player's goals and assists, respectively. Start with an empty dictionary. Then, use a loop to cycle through the text file and add key-value pairs to the dictionary. Close the text file and process the dictionary to print the stats and determine the top scorer as before. Printing the stats for each player is the most challenging part of this program. The required output should be the same well-formatted table as below: PLAYER COLUMN: 10 characters wide and left-aligned. GOALS COLUMN: 6 characters wide and centered. ASSISTS COLUMN: 8 characters wide and centered.
This assignment requires you to create a dictionary by reading the text file.
Text file name: LightningP
Text file contents:
Stamkos
35
38
Maroon
29
33
Point
50
55
Kucherov
55
65
Killorn
33
40
The dictionary should have player names for the keys. The value for each key must be a two-element list holding the player's goals and assists, respectively. Start with an empty dictionary. Then, use a loop to cycle through the text file and add key-value pairs to the dictionary. Close the text file and process the dictionary to print the stats and determine the top scorer as before. Printing the stats for each player is the most challenging part of this program. The required output should be the same well-formatted table as below:
- PLAYER COLUMN: 10 characters wide and left-aligned.
- GOALS COLUMN: 6 characters wide and centered.
- ASSISTS COLUMN: 8 characters wide and centered.
- TOTAL COLUMN: 6 characters wide and centered.
Example output:


Read the file line by line and store the data in dictionary
Then, we can display the values and iterate again to find the maximum
Step by step
Solved in 3 steps with 1 images









