title: How to show word onscreen in Pygame through a series of functions
body: <p>I think there are 2 problems that I have:</p>
  
  <ol>
  <li><p>In <code>chooseTheme()</code>, either the return statements or the keys pressed code doesn't work.</p></li>
  <li><p>The <code>randWord()</code> function doesn't stop when in the while not done main, it keeps randomizing the word list.</p></li>
  </ol>
  
  <p>The message in <code>chooseTheme()</code> prints.</p>
  
  <p>I've run lines 22-27 separately and it prints out a single word which is what I want.</p>
  
  <p>When trying <code>randWord("Nations")</code> instead of <code>randWord(chooseTheme())</code> the text shows up but it iterates through the all of the words rather than just picking one.</p>
  
  <pre><code>import random
  import pygame
  
  
  pygame.init()
  
  display_width = 1102
  display_height = 625
  
  moccasin = (255, 228, 181)
  BLACK = (0, 0, 0)
  
  screen = pygame.display.set_mode((display_width, display_height))
  pygame.display.set_caption("Hangman")
  clock = pygame.time.Clock()
  font = pygame.font.SysFont(None, 25)
  background = pygame.image.load("world_map.jpg")
  
  
  def randomWord(theme):
      if theme == "Nations":
          with open("countries_europe.txt") as f:
              word_list = ""
              for word in f:
                  word_list = word_list + word
              f.close()
              x = random.choice(word_list.split())
              screen_word = font.render(x, True, BLACK)
              screen.blit(screen_word, [display_width/2, display_height/2])
      elif theme == "Capitals":
          with open("capitals_europe.txt") as f:
              word_list = ""
              for word in f:
                  word_list = word_list + word
              f.close()
              x = random.choice(word_list.split())
              screen_word = font.render(x, True, BLACK)
              screen.blit(screen_word, [display_width/2, display_height/2])
  
  
  def chooseTheme():
      category_text = font.render("Choose a theme:  NATIONS [N] CAPITALS [C]", True, BLACK)
      screen.blit(category_text, (200, display_height/2))
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              done = True
          elif event.type == pygame.KEYDOWN:
              if event.key == pygame.K_n:
                  return "Nations"
              elif event.key == pygame.K_c:
                  return "Capitals"
  
  
  done = False
  
  while not done:
      screen.blit(background, (0, 0))
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              done = True
  
      randomWord(chooseTheme())
  
      pygame.display.flip()
      clock.tick(60)
  
  pygame.quit()
  </code></pre>
  
  <p>When the keys N or C are pressed, the "Choose theme:" question should disappear and a random word should print onscreen from one of the .txt files.</p>