input: def generateMarkov(text: str) -> str:
      """ Generate a Markov chain-based text from the given input text.
      >>> 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?')
      '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.'
      """
output:     import random
      words = text.split()
      markov_dict = {}
  
      for i in range(len(words) - 1):
          if words[i] not in markov_dict:
              markov_dict[words[i]] = []
          markov_dict[words[i]].append(words[i + 1])
  
      current_word = random.choice(words)
      result = [current_word]
  
      while len(result) < len(words) and current_word in markov_dict:
          next_word = random.choice(markov_dict[current_word])
          result.append(next_word)
          current_word = next_word
  
      return ' '.join(result[:len(words)//2])