Question: Create the function team_average which has the following header def team_average(filename): This function will return the average number of games won by the Red Sox

Create the function team_average which has the following header def team_average(filename): This function will return the average number of games won by the Red Sox from a text file with entries like this 2011-07-02 Red Sox @ Astros Win 7-5 2011-07-03 Red Sox @ Astros Win 2-1 2011-07-04 Red Sox vs Blue Jays Loss 7-9 This function should create a file object for the file whose name is given by the parameter filename. If the file cannot be opened, use a try/except statement to print an error message and don't do any further work on the file. The function will count the number of lines and the number of games the Red Sox won and use these values to compute the average games won by the team. This average should be expressed as an integer.

it has to be as simple as possible

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!