input: Write a function to generate a Markov chain from a given text input. The function should split the text into words, create a Markov chain dictionary where each word leads to a dictionary of following words with their frequencies. Then, it should generate a new text of approximately 100 words using this Markov chain. If the chain runs out of words before reaching 100, it should stop and return the generated text. If the input text is empty, the function should return an empty string.
  
  def generateMarkov(text):
    words = text.split(' ')
    markovChain = {}
  
    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):
      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
  
  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?'") != ""
  assert generateMarkov("") == ""
  assert generateMarkov("The quick brown fox jumps over the lazy dog.") != ""
  assert generateMarkov("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") != ""
  assert generateMarkov("Hello world!") != ""
output: 
  import random
  
  def generateMarkov(text):
      if not text:
          return ""
      
      words = text.split(' ')
      markovChain = {}
  
      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.keys()))
      generatedText += current
  
      while len(generatedText.split()) < 100:
          if current not in markovChain:
              break
          choices = markovChain[current]
          next_word = random.choices(list(choices.keys()), weights=list(choices.values()))[0]
          generatedText += " " + next_word
          current = next_word
  
      return generatedText
  