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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  • 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.
 
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Stack operations
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education