def inputWords(posTypes,form): words = [] for m in form: if m in posTypes: words.append(input(m + ' ')) return words def generateMadLib(posTypes,form,words): s = '' i = 0 for m in form: if m == 'DET': s += det(words[i]) elif m in posTypes: s += words[i] i += 1 elif m == 'NewLine': s += '\n' else: s += m print(s) def det(noun): if noun[0] in 'aeiou': return 'an ' else: return 'a ' def main(): words = [] #Here are all the types of fillers you can use to create your madlib posTypes = ['NOUN','NOUN (PLURAL)','NOUN','NOUN','PLACE','NOUN','ADJECTIVE'] posTypes += ['VERB (SINGULAR SUBJECT)','VERB (PLURAL SUBJECT)','NUMBER','BODY PART'] # Create your form. # Include all spaces in the strings which you want on the output # 'DET' means that a or an should be printed before the next word. # NewLine is just a human-friendly signal that you want a '\n' # form = ['Be kind to your ','NOUN','-footed ','NOUN (PLURAL)','NewLine'] form += ["For a duck may be somebody's ",'NOUN','NewLine',] form += ['Be kind to your ','NOUN',' in ','PLACE','NewLine'] form += ['For they may be ','DET','NOUN'] words = inputWords(posTypes,form) generateMadLib(posTypes,form,words) main()