Question
Help! I keep getting errors on this question! The Question: The errors: My code: def print_stats(stats): total_points = 0 total_rebounds = 0 total_assists = 0
Help! I keep getting errors on this question!
The Question:
The errors:
My code:
def print_stats(stats):
total_points = 0 total_rebounds = 0 total_assists = 0
for player in stats: name, points, rebounds, assists = player print(f"{name} scored {points} points, grabbed {rebounds} rebounds, and made {assists} assists.")
total_points += points total_rebounds += rebounds total_assists += assists
print(" Total Points: ", total_points) print("Total Rebounds: ", total_rebounds) print("Total Assists: ", total_assists)
stats = [('Jefferson', 706, 88, 57), ('Haroll', 615, 62, 62), ('Tucker', 551, 137, 17)]
print_stats(stats)
Back in Exercise 3.2 you created a program for JMU Basketball that printed the scoring for a single player, and in Exercise 3.3 a function that returned all the statistics for a single player. JMU Basketball would now like you to create a function that will print the statistics for a large number of players all at once. Name your program even_more_stats.py. Write a function called print_stats( ) that does two things: 1. prints the names and individual statistics for any number of players; and 2. prints the total number of points, rebounds, and assists for the entire group of players. The function will take a single parameter, a list that contains all the statistics for the players. A sample list is as follows: [('Jefferson', 706, 88, 57), ('Hazel1', 615, 62, 62), ('Tucker' , 551, 137, 17) ] (Statistics from 2020-2021 JMU Women's Basketball Team) The list consists of tuples, each of which lists a player's name, their total points, total rebounds, and total assists for the season. Your code should print a line for each player (as demonstrated below), and then print the total points, total rebounds, and total assists, calculated for the entire list. The output should be as follows: >> print_stats([('Bird', 500, 100, 50), ('Jordan', 450, 90, 45)]) Bird scored 500 points, grabbed 100 rebounds, and made 50 assists. Jordan scored 450 points, grabbed 90 rebounds, and made 45 assists. Total Points: 950 Total Rebounds: 190 Total Assists: 95 Test Failedi Submission does not pass doestring checks: /autograder/submission/even_more_stats.pyilt1: D300 Use "*"triple double quotes"an /autograder/submission/even_more_stats.py:11:1: D103 Missing doestring in public function PEP 8 checks (0.0/1.0) Test Failedi submission does not pass peps checks: /autograder/subonission/even_more_stats.py:19:101: E501 line too long (105 > 100 characters) /autograder/submission/even_more_stats.py:29:1: E305 expected 2 blank lines after elass or function definition, found 1 Test one player (0.0/4.0)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