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
dog
deer
lion
bear
horse
cow
leopard
whale
-----------------------------------------------------info.txt-------------------------------------------------------------
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