Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions