Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This must be in Python! Write a function that accepts a filename as input argument and reads the file and saves each line of the

This must be in Python!

Write a function that accepts a filename as input argument and reads the file and saves each line of the file as an element in a list (without the new line (" ")character) and returns the list. Ask the user :

 Enter the input file name: 

Each line of the file has comma separated values: For example

 Alan,Williams,27 Layla,Trinh,21 Brayden,Huang,22 

Then the function should return a list such as :

 ['Lucas,Turing,22', 'Alan,Williams,27', 'Layla,Trinh,21', 'Brayden,Huang,22'] 

Should catch the exception if file not existed. Let the system decide to display the error message.

image text in transcribed

O_exc.py 1 def list fr om_file(file_name): # Your code goes here # 4 5 6 7 def main): file_name - input("Enter the input file name: ) # Your code goes here # 13 10 12 13 14 main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions