in python please thanks!!!
12.7 LAB 12 - Part 2: File 1/0 and word frequencies Write a program that first reads in the name of an input file and then reads the file. The input file contains words, each on a separate line. You'll need to remove the newline at the end of each line (see note below). Using a dictionary, keep track of the word and frequency of each word (the number of times each word appears in the file). Output each word and frequency, one word per line, to a file named 'myfile.txt'. Ex: If the input is: inputl.txt and the contents of input1.txt are: hello cat man hey dog boy Hello man cat woman dog Cat hey boy
the file myfile.txt should contain: hello 1 cat 2 man 2 hey 2. dog 2 boy 2. Hello 1 woman 1 Cat 1 Note: There is a newline at the end of each line of the input file, requiring you to strip('\n') from each line before you add it to your dictionary. input1.txt is available to download.
12.7 LAB 12 - Part 2: File 1/0 and word frequencies Write a program that first reads in the name of an input file and th
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
12.7 LAB 12 - Part 2: File 1/0 and word frequencies Write a program that first reads in the name of an input file and th
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!