# Write a function that takes a sentence, # check if there are repeated words. # Your program will return a list of the repeated words # Note: repeated words are words that occur multiple times in consecutive # multiple occurrences of the same word should be reported once # # If there is no repeated word or the file is empty, # return [] # # For example, if a sentence contains # 'I will do more more practice and my bring my my my questions to class' # # Your program will return # ['more', 'my'] # # Note that your choice of data structure can affect the return formats. # For this practice, any formats would be fine. # # You should consider: # - What data structure would you be using? # - Why would you use that data structure? # def check_repeated_words(sentence): result = [] words = sentence.split() for i in range(0, len(words)-1): if words[i] == words[i+1]: if words[i] not in result: result.append(words[i]) return result print(check_repeated_words('I will do more more practice and my bring my my my questions to class'))