Write A Function Main That Removes All The Occurrences Of A Specified String From A Text File Your Program Should Pro 1 (58.55 KiB) Viewed 237 times
Write a function "main" that removes all the occurrences of a specified string from a text file. Your program should prompt the user to enter a string to be removed from a file. You can use the file with name test6.txt Your program should count the words before removing and after removing the keyword. Use the message exactly like the sample run. Here is a sample run: <Output> Enter a keyword to be removed: you Word count before removing the keyword: 601 count number of you in the text: 10 Word count after removing the keyword: 591 <End Output> For example: Test Input Result keyword=input("Enter a keyword to be removed: ").lower().strip() you main(keyword) keyword=input("Enter a keyword to be removed: ").lower().strip() copy main(keyword) keyword=input("Enter a keyword to be removed: ").lower().strip() user main(keyword) Enter a keyword to be removed: you Word count before removing the keyword: 681 Count number of you in the text: 10 Word count after removing the keyword: 591 Enter a keyword to be removed: copy Word count before removing the keyword: 601 Count number of copy in the text: 5 Word count after removing the keyword: 596 Enter a keyword to be removed: user Word count before removing the keyword: 681 Count number of user in the text: 0 www.com
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!