Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are going to create some Mad Libs. There are two files available: a word list full of common words (words.txt), and a short story

You are going to create some Mad Libs. There are two files available: a word list full of common words ("words.txt"), and a short story ("story.txt"). Process both files line-by-line in order to replace the words from the first file in the short story with the string "____" (four underscores). Then, print the resulting story, each line of the story on its own line.

One issue you may encounter: You cannot loop through a file again after you have read its contents once. Solve this issue by storing the words file in a list before processing the story.

In python

words.txt

cat that phat chat combat bat fat hat rat
The cat in the hat came back the other day, chasing a bat and a rat. I asked the cat in the hat why the bat and the rat were his combat. He said, "that bat and the rat said I was fat!" The bat and the rat groaned and turned to me. "We said he was phat!" they said as a plea. I calmed and spoke kindly to the cat with the hat, "Can't we make this into a nice chat?" And that was the end of that.

story.txt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

What is the significance of digitalization?

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago