试图得到它,以便它输入与原始字符串中出现的特定单词相同的次数,并将其替换为输入的每个单词。
def replace_parts_of_speech (replaced, part_of_speech):
'''Finds and replaces parts of speech with words '''
new_line=''
for i in range (replaced.count(part_of_speech)):
new=input('Enter '+ part_of_speech +':')
new_line = replaced.replace(part_of_speech,new,1)
return new_line