Question: python Write a function named read_data() that builds a list of lists from the provided data file (nutrition_data.csv). In this function you'll need to: Create
python
Write a function named "read_data()" that builds a list of lists from the provided data file (nutrition_data.csv). In this function you'll need to:
Create an empty list variable that will contain the list of lists
Create a while loop that reads each line from the data file. Each line in the file contains a comma separated string of four items. As you read the line, also strip the " " from the end of the line and store it temporarily in a variable
Use a Split() function to split the temporary line variable based on a comma. This will create a list of those items.
Append this new small list to the main list variable created in the first bullet point
Close the file
Return the new main list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
