title: Python recursive function doesn't return random choice
body: <p>I am trying to get random work in python using <code>random</code> module. My function is as below:</p>
  
  <pre><code>import random
  
  word_file = "/usr/share/dict/words"
  WORDS = open(word_file).read().splitlines()
  
  
  def get_random_word(max_length=None):
      word = random.choice(WORDS)
      print(word)
  
      if not max_length:
          return word
  
      if len(word) &gt; max_length:
          get_random_word(max_length)
  
      return word
  </code></pre>
  
  <p>When I import this function in <code>ipython</code> console and run as <code>get_random_word(max_length=5)</code>, I get this result:</p>
  
  <pre><code>Latasha's
  Hammond's
  evacuated
  aviary
  misconducted
  airfare's
  controllable
  unduly
  gaunt
  Out[32]: "Latasha's"
  </code></pre>
  
  <p>As you see from output, function calls itself until it finds the word with length less than 5. But at the end it returns very first random word. What is wrong with my function?</p>