# alternate version of madlibs2.py # assume you have the following: # work_text: a string that has been prepared for madlibs # # A string in quotes looks like this: # "To or not to . That is the ." # # The part of speech that needs to be replaced is indicated with < >. # # Write code that prompts the user for all the words needed to # complete the quote, and then prints out the new version of the # quote, in quotes. work_text = "To or not to . That is the ." # each item in worklist except for the one at index 0 originally started with < worklist = work_text.split('<') for i in list(range(1, len(worklist))): sublist = worklist[i].split('>') # at 0 is the prompt; at 1 is the rest sublist[0]= input("Please give me a "+sublist[0]+": ") # replace with user input worklist[i] = ''.join(sublist) finished = ''.join(worklist) print("\""+finished+"\"")