ideas that the names correspond to when using sequences like lists or stringsyou generally need names not only for the whole collectionbut also parts like items and characters or substringsand often indices that locate parts of the collection plan the overall approach to the problem using mixture of python and suggestive phrases (called pseudo-codethe idea is to refine it to place where you can fairly easily figure how to replace the phrases with python replace your pseudo-code parts with python if you had concrete example to guide youyou may want to test with one of more further concrete examples with different specific datato make sure you come up with code for generalization that works in all cases this is the process of abstraction recognize where something is being repeated over and overand think how to structure appropriate loops can you incorporate any patterns you have seen beforeif you need to create successive modification loopthink of how to approach the first repetition and then how to modify the data for the later times through the loop usually you can make the first time through the loop fit the more general pattern needed for the repetitions by making appropriate initializations before the loop check and test your codeand correct as necessary the revised mad lib program there is still an issue for use of getkeys in the mad lib programthe returned list has unwanted repetitions in it we can easily create collection without repetitionshowone approach is to make set from the list returned neater approach would be to just have the getkeys function return set in the first place we need to slightly change to getkeysdocumentation string and the final return line this will be included in new version of the mad lib programwhich makes it easy to substitute new story we will make the story' format string be parameter to the central methodtellstory we will also put the clearly identified step of filling the dictionary with the user' picks in separate function we will test tellstory with the original story note the changes included in madlib py and run""madlib py interactive display of mad libwhich is provided as python format stringwith all the cues being dictionary formatsin the form {cuein this versionthe cues are extracted from the story automaticallyand the user is prompted for the replacements original verison adapted from code of kirby urner ""def getkeys(formatstring)'''formatstring is format string with embedded dictionary keys return set containing all the keys from the format string ''keylist list(end repetitions formatstring count('{'for in range(repetitions)start formatstring find('{'end pass the '{end formatstring find('}'startkey formatstring[start endkeylist append(keymay add duplicates return set(keylistremoves duplicatesno duplicates in set objects and methods