user
Task: Create a program to detect and remove duplicate words from a given sentence

No input


assistant
def remove_duplicates(sentence):
  word_list = sentence.split() # split sentence into a list of words
  new_list = [] # new list that will contain uniques words

  # loop thru each word in the list
  for word in word_list:
    if word not in new_list: # add a word to the new list if the word is unique
      new_list.append(word)

  # join words in the new list to form a new sentence
  return ' '.join(new_list)