input: from typing import Dict, List
  
  def generateMarkov(text: str) -> str:
      """
      Generate a Markov chain based on the given text input. The function splits the text
      into words and builds a dictionary where each word is a key and the value is another
      dictionary where the keys are the next words and the values are the counts of their
      occurrences. The function then generates a new text based on the Markov chain by
      randomly selecting the next word based on the occurrences.
  
      >>> 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')
      'bank, and of having nothing to do: once or twice she had no pictures or conversation?'
      >>> generateMarkov('hello world hello world')
      'hello world hello world'
      """
      words = text.split(' ')
      markovChain: Dict[str, Dict[str, int]] = {}
  
      for i in range(len(words) - 2):
          current = words[i]
          next = words[i + 1]
          if current in markovChain:
              if next in markovChain[current]:
                  markovChain[current][next] += 1
              else:
                  markovChain[current][next] = 1
          else:
              markovChain[current] = {next: 1}
  
      generatedText = ""
      current = random.choice(list(markovChain))
      generatedText += current
  
      for i in range(100):
          if current not in markovChain:
              break
          choices = markovChain[current]
          choices = [
              key for key, value in choices.items()
              for i in range(value)
          ]
          try:
              current = random.choice(choices)
              generatedText += " " + current
          except:
              break
  
      return generatedText
output:     import random
  
      words = text.split(' ')
      markovChain: Dict[str, Dict[str, int]] = {}
  
      for i in range(len(words) - 1):
          current = words[i]
          next = words[i + 1]
          if current in markovChain:
              if next in markovChain[current]:
                  markovChain[current][next] += 1
              else:
                  markovChain[current][next] = 1
          else:
              markovChain[current] = {next: 1}
  
      generatedText = ""
      current = random.choice(list(markovChain))
      generatedText += current
  
      while len(generatedText.split(' ')) < len(words):
          if current not in markovChain:
              break
          choices = markovChain[current]
          choices = [
              key for key, value in choices.items()
              for i in range(value)
          ]
          try:
              current = random.choice(choices)
              generatedText += " " + current
          except:
              break
  
      return generatedText