input: Write a function to generate a Markov chain given a text input. The function should take a string as input and return a generated text based on the Markov chain model. If the input text is empty, the function should return an empty string.
  assert generateMarkov('Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?')== 'the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the the'
  assert generateMarkov('')== ''
  assert generateMarkov('I am happy. I am sad.')== 'happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily happily'
output: def generateMarkov(text):
      if not text:
          return ''
      words = text.split()
      word_count = {}
      for i in range(len(words) - 1):
          if words[i] in word_count:
              word_count[words[i]].append(words[i + 1])
          else:
              word_count[words[i]] = [words[i + 1]]
      result = []
      current_word = words[0]
      for _ in range(50):
          if current_word in word_count:
              next_word = word_count[current_word][0]
              result.append(next_word)
              current_word = next_word
          else:
              break
      return ' '.join(result)