Create a file quote.txt in your project with the following quote: we observe today not a victory of party but a celebration of freedom symbolizing an end as well as a beginning signifying renewal as well as change Your program will make a dictionary with each key being a word from the file and each value being a list of integers. Each list will contain the row numbers the corresponding word appears in. i.e. “a” appears in lines 1, 2, and 4 so your dictionary should have { “a” : [1, 2, 4] } as one of its key/value pairs. Hint: You’ll need nested loops. The outer for loop should read one line from the file at a time and use the enumerate function (so you can keep track of which line you’re currently reading) After the file is read, print the data in your dictionary. Your program’s output should resemble the following output: observe 1 today 1 not 1 a 1 2 4 victory 1 of 2 3 party 2 but 2 celebration 2 freedom 3 symbolizing 3 an 3 end 3 as 4 4 5 6 well 4 5 beginning 4 signifying 5 renewal 5 change 6 Language= python.
Create a file quote.txt in your project with the following quote: we observe today not a victory of party but a celebration of freedom symbolizing an end as well as a beginning signifying renewal as well as change Your program will make a dictionary with each key being a word from the file and each value being a list of integers. Each list will contain the row numbers the corresponding word appears in. i.e. “a” appears in lines 1, 2, and 4 so your dictionary should have { “a” : [1, 2, 4] } as one of its key/value pairs. Hint: You’ll need nested loops. The outer for loop should read one line from the file at a time and use the enumerate function (so you can keep track of which line you’re currently reading) After the file is read, print the data in your dictionary. Your program’s output should resemble the following output: observe 1 today 1 not 1 a 1 2 4 victory 1 of 2 3 party 2 but 2 celebration 2 freedom 3 symbolizing 3 an 3 end 3 as 4 4 5 6 well 4 5 beginning 4 signifying 5 renewal 5 change 6 Language= python.
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
Related questions
Question
- Create a file quote.txt in your project with the following quote:
of party but a celebration
of freedom symbolizing an end
as well as a beginning
signifying renewal as well
as change
- Your program will make a dictionary with each key being a word from the file and each value being a list of integers.
- Each list will contain the row numbers the corresponding word appears in.
- i.e. “a” appears in lines 1, 2, and 4 so your dictionary should have { “a” : [1, 2, 4] } as one of its key/value pairs.
- Hint: You’ll need nested loops. The outer for loop should read one line from the file at a time and use the enumerate function (so you can keep track of which line you’re currently reading)
- After the file is read, print the data in your dictionary. Your program’s output should resemble the following output:
today 1
not 1
a 1 2 4
victory 1
of 2 3
party 2
but 2
celebration 2
freedom 3
symbolizing 3
an 3
end 3
as 4 4 5 6
well 4 5
beginning 4
signifying 5
renewal 5
change 6
Language= python.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT