def mad(msgs,words): str = '' i = 0 for m in msgs: if m == 'Det ___': str += det(words[i]) + words[i] i += 1 elif m == '___': str += words[i] i += 1 elif m == 'NewLine': str += '\n' else: str += m print(str) def det(noun): if noun[0] in 'aeiou': return 'an ' else: return 'a ' def main(): words = [] posList = ['NOUN','NOUN (PLURAL)','NOUN','NOUN','PLACE','NOUN'] for pos in posList: words.append(input(pos + " ")) # Include all spaces in the strings which you want on the output # 'Det ___' means that a or an should be printed before the word. # NewLine is just a human friendly signal that you want a '\n' msgs = ['Be kind to your ','___','-footed ','___','NewLine'] msgs += ["For a duck may be somebody's ",'___','NewLine',] msgs += ['Be kind to your ','___',' in ','___','NewLine'] msgs += ['For they may be ','Det ___'] mad(msgs,words) main()