1. Engineering
  2. Computer Science
  3. i almost have this python problem solved as seen in...

Question: i almost have this python problem solved as seen in...

Question details

I almost have this python problem solved. As seen in the third picture below the results wants my prompted questions to be separated with a space and im not sure how to do this with the following directions. I must use the list and dictionary to complete this.

The MadLib is longer .You can only use two variables - a dictionary containing the substitution values and a list containing the string literals for the text of the story . You may only use a single print statement that references values in the dictionary and list. You may not use any string literals such as Hi in the print statement. Heres a MadLib invitation form. Dear name1. You are adverb invited! name2 is having a theme party! Its going to be at a place oday of the week Please make sure you show up at Lime , or else you will be required to _verb_ a/an _animal with your body part. Like the previous assignment, you must prompt for each fill-in-the-blank value before printing the entire MadLib with the substitutions. The values should be placed in a dictionary with the fill-in-the-blank as the key. All prompts should include a question mark. Use blanks instead of_s in your prompts (ie._a_place_ is just a place in the prompt) blanks fill in the blank1 -input (fill in the blank?) Since you cannot use string literals in the print statement, you will need to place them in a list which you can reference in the print statement. To print multiple lines with a single print statement you will need to include . in the string literals you put in the list. There should be no extra spaces in the printed MadLib so you will need to append the strings with in a single expression rather than use, to separate the values in the print statement. madlib- 1Hello, J print (madlib [0] + blanks[ーfill-in-the-blank-] + madlib [1]) This should give you a pretty good start on the assignment. Remember to declare the variables before you use themmadiblist.py Load default template... 1 # Obtain values for each fill-in-the-blank in the MadLib and place them in a dictionary. 2 # For n blanks, split the input sentence into at least n+1 parts. Insert spaces and \n wherever needed 3 #eg. Hello 4 # Welcome to 6 # madlib [Hello , 7# 8# Welcome to 9# ie madlib = [Dear , You are , 12 13 14 15 16 17 18 19 2e 21 invited! . is having a , partyl Its going to be at, on , . Please make sure you show up at ,, , or else you will be required to , a/an, with your ,. ] 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 lines.! # Define a list of strings containing the MadLib # blanks[ name] Henry # blanks[ place] Fort Collins name1=input(name1?) adverb-input(adverb?) name2-input(name2?) #-name2-input(name2 ? ) #-theme-:input(theme ?) #-a-place. :input(a place?) # day of the week :input (day of the week?) #-time. input(tine?),-verb-:input(verb?) #ーanimal-:input (animal?) #-body-part-input(body part?) text, including blanks, punctuation, and new blanks = {-namel-:namel, -adverb :adverb, -name2_.:name2, -theme-:input(theme ?),_a_place..:input(a place ?), -day-of-the-week-:ǐnput( day of the week?), -time-..input (time?),一verb-:input( verb ?), animal-input(animal?), -body part # Print the MadLib by concatenating values from the list and print (madlib[이-blanks[ name1 ]+, + madlib[1]+ madlib [2] dictionary -blanks[ adverb ]+madlib[31-madlib[4]-blanks [ name2 ]-madlib[5]-blanks[ madlib[7]+blanks[_a_place]+madlib[8]+blanks[_day_of_the_week]+madlib[9]+madlib[10]+blanks[_time_]+ madlib[11]+madlib[12]+madlib[1 45 +madlib[16]+blanks[_body_part_1+madlib[17]) 46 47 48 #blanks[ーanimal-]hmadlib[16]Hnadlib [17]+madlíb[18]+blanks(-body-part-]+madlib/191)1: Prompts Output differs. See highlights below. Special character legend namel adverb name2 theme Input a place day of the week time verb animal body part name1?adverb?name2?theme?a place?day of the week?time?verb?animal?body F You are adverb invited! name2 is having a theme party! Your output starts Its going to be at a place on day of the week with lease make sure you show up at time, or else you will be required to verba/an animale with your body part namel adverb? name2?4 theme Expected output a place?e starts with day of the week time verb?d animal? body part

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution