return keylist look the code over and see that it makes sense see how we continuously modify startendkeyand keylist since we have coded this new part as functionit is easy to test without running whole revised mad lib program we can just run this function on some test datalike the original storyand see what it does run the example program testgetkeys py'''test the function to extract keys from format string for dictionary ''def getkeys(formatstring)'''formatstring is format string with embedded dictionary keys return list containing all the keys from the format string ''keylist list(end repetitions formatstring count('{'for in range(repetitions)start formatstring find('{'end end formatstring find('}'startkey formatstring[start endkeylist append(keyreturn keylist originalstory ""once upon timedeep in an ancient junglethere lived {animalthis {animalliked to eat {food}but the jungle had very little {foodto offer one dayan explorer found the {animaland discovered it liked {foodthe explorer took the {animalback to {city}where it could eat as much {foodas it wanted howeverthe {animalbecame homesickso the explorer brought it back to the jungleleaving large supply of {foodthe end ""print(getkeys(originalstory)the functions should behave as advertised look back on the process described to come up with the getkeys function one way of approaching the creative process of coding this function was provided there are many other results and approaches possiblebut the discussion did illustrate number of useful ideas which you might adapt to other problemsin different orders and proportionsthat are summarized in the next section creative problem solving steps clearly define the problem encapsulating the problem in function is usefulwith inputs as parameters and results returned include complete documentation stringand clear example (or examplesof what it is to do if the problem is too complicated to just solve easilystraight awayit is often useful to construct representative concrete case and write down concrete steps appropriate to this problem think of the data in the problemand give names to the pieces you will need to refer to clearly identify the mad libs revisited