title: How to obtain a random word using function and dictionary? (Python 3)
body: <p>The user has to select a category. And from there, the program has to generate a random word from the category list. If the user selected an invalid category, the program will prompt the user to choose a category again (loop the askCat function again).</p>
  
  <pre><code>import random
  
  #Make word dictionary
  wordDict = {'Animals':['Giraffe','Dog','Dolphin','Rabbit','Butterfly'], \
              'Fruits': ['Apple','Pineapple','Durian','Orange','Rambutan'], \
              'Colours': ['Red','Blue','Yellow','Green','Purple'], \
              'Shapes': ['Heart','Circle','Rectangle','Square','Diamond']}
  
  #Determine word category and random word
  def askCat (wordDict):
      category = str( input ("To start the game, please choose a category: \n Animals (a), Fruits (f), Colours (c), Shapes (s) "))
      print()
      if category == 'a':
          print ("You chose the Animals category.")
          cat = (wordDict['Animals'])
      elif category == 'f':
          print ("You chose the Fruits category.")
          cat = (wordDict['Animals'])
      elif category == 'c':
          print ("You chose the Colours category.")
          cat = (wordDict['Animals'])
      elif category == 's':
          print ("You chose the Shapes category.")
          cat = (wordDict['Animals'])
      else:
          print ("You entered an invalid category. Try again!")
          print()
          askCat(wordDict)
      return random.choice(cat)
  
  #Print random word
  randWord = askCat(wordDict)
  print (randWord)
  </code></pre>
  
  <p>When on the first try, the user enter a valid category, the program works just fine. However, the problem I'm facing is that, when the user enter an invalid category the first time, and when he enter a valid category the second time, the program don't work anymore. <br>
  Please do help! Thanks (:</p>