Question: Python You will require to read data from a file and perform operations on the data Create a file named csc101.py 1. Using the open

Python

You will require to read data from a file and perform operations on the data

Create a file named csc101.py

1. Using the open function in python, read the file info.txt. You MUST use try/except for error handling. If the file is not found, show a message that says "File not found"

2. Read the data from the file using readlines() method. Make sure to close the file after reading it

3. Take the data and place it into a list. The data in the list will look like the list below

['CSC 101 ', 'BMCC ', ' ', 'Good luck on your project! ', ' ', 'name ', ' ', 'email ', 'dog ', 'deer ', 'lion ', 'bear ', ' ', 'horse ', 'cow ', 'leopard ', 'whale ']

4. Create a function called remove_new_line_char_from_list(list) that removes all the items from the list. You can use the pop() method with looping. https://www.w3schools.com/python/ref_list_pop.asp TAB Correctly i = 0 ls = your list while i < len(ls): if ls[i] == " ": ls.pop(i) i += 1

5. Create a function called remove_new_line_char_from_string(list) that loops over the list and remove the new line character ( ) from each string

6. Create a function called modify_name that finds(list, your_name) "name" and replace it with your full name

All functions you were asked to create must take the list as an argument. These functions do not have a return value. Your functions will modify the list of items. You can always print the list to ensure your code modified the list in each function.

-----------------------------------------------------info.txt-------------------------------------------------------------

CSC 101

BMCC

Good luck on your project!

name

email

dog

deer

lion

bear

horse

cow

leopard

whale

-----------------------------------------------------info.txt-------------------------------------------------------------

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!