Answered step by step
Verified Expert Solution
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.
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
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