Question: IN PYTHON PLEASE. You will read in the text files from the file, then make a program that will let the user fill out the

IN PYTHON PLEASE.
You will read in the text files from the file, then make a program that will let the user fill out the Mad Libs. The goal is to write a program to allow you to play Mad Libs
The program begins by prompting the user for input and output file names. Then the program reads the input file, prompting the user to fill in any placeholders that are found without showing the user the rest of the story. As the user fills in each placeholder, the program is writing the resulting text to the output file. After the input file is processed, the program asks the user if they want to see the resulting output file, in which case the output file is opened and its contents are echoed to the screen. The user is then given the option of processing another MadLib file.
Notice that if an input file is not found, the user is re prompted. No re prompting occurs for the output file. If the output file does not already exist, it is created. If it already exists, overwrite its contents.
Placeholders are represented as input tokens that begin with "". Your program should break the input into lines and break the lines into tokens so that you can look for all its placeholders. Normal text (non-placeholders) can be written directly to the output file as-is, but placeholders cause the user to be prompted. The user's response to the prompt is written to the
output file, rather than the placeholder itself. You should accept whatever response the user gives, even a multi-word answer or blank answer.
You may assume that each word/token from the input file is separated from neighboring words by a single space. In other words, when you are writing the output, you may place a single space after each token to separate them. You do
not need to worry about blank spaces at the end of lines. It's okay to place a space after each line's last token in the file.
Sometimes a placeholder has multiple words in it, separated by a hyphen (-),such as . As your program discovers a placeholder, it should convert any hyphens into spaces. Any hyphens that appear outside of a placeholder, such as in the other text of the story, should be retained and not converted into spaces.
Do not make unnecessary assumptions about the input. For example, an input file could have characters in it that are not part of placeholders, and these should be retained and included in the output. You may assume that a placeholder token will contain at least one character between its (in other words, no file will contain the token
REQUIREMENTS: You CANNOT use built in string methods. You must manipulate strings using its index. You must use file I/O for this program.
Must have a main function that is called "generate story"
Sample input file and the example output log is shown in the pictures
IN PYTHON PLEASE. You will read in the text files from the
file, then make a program that will let the user fill out
One of the most characters in fiction is named "Tarzan of the ." Tarzan was raised by a/an and lives in the jungle in the heart of darkest . He spends most of his time eating and swinging from tree to Whenever he gets angry, he beats on his chest and says, " !" This is his war cry. Tarzan always dresses in shorts made from the skin of a/an and his best friend is a/an chimpanzee named Cheetah. He is supposed to be able to speak to elephants and . In the movies, Tarzan is played by Welcome to the game of Mad Libs. I will ask you to provide several words and phrases to fill in a mad lib story. The result will be written to an output file. Input file name: oops.txt File not found. Try again: tarzan.txt Output file name: outi.txt Please type an adjective: silly Please type a plural noun: apples Please type a noun: frisbee Please type an adjective: hungry Please type a place: Nashville, TN Please type a plural noun: bees Please type a noun: umbrella Please type a funny noise: burp Please type an adjective: shiny Please type a noun: jelly donut Please type an adjective: beautiful Please type a plural noun: spoons Please type a person's name: Keanu Reeves Your Madlib story has been created. Do you want to see the resulting story? (YN) Y Here is the resulting Madlib: One of the most silly characters in fiction is named "Tarzan of the apples." Tarzan was raised by a/an frisbee and lives in the hungry jungle in the heart of darkest Nashville, TN. He spends most of his time eating bees and swinging from tree to umbrella. Whenever he gets angry, he beats on his chest and says, "burp!" This is his war cry. Tarzan always dresses in shiny shorts made from the skin of a/an jelly donut and his best friend is a/an beautiful chimpanzee named Cheetah. He 18 supposed to be able to speak to elephants and spoons. In the movies, Tarzan is played by Keanu Reeves. Do you want to process another Mad Lib? (YIN)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!