input: Write a python function to replace specified words in a text based on a given dictionary.
  assert replace_words("The bodybuilders are lifting weights.", {"bodybuilders": "athletes"}) == "The athletes are lifting weights."
  assert replace_words("She loves her dogs and cats.", {"dogs": "puppies", "cats": "kittens"}) == "She loves her puppies and kittens."
  assert replace_words("The morning exercises include dips and curls.", {"morning": "early morning", "dips": "push-ups", "curls": "bicep curls"}) == "The early morning exercises include push-ups and bicep curls."
output: def replace_words(text, replacements):
      words = text.split()
      for i, word in enumerate(words):
          if word in replacements:
              words[i] = replacements[word]
      return 'string '.join(words)