title: Why am I getting an unboundLocalError?
body: <p>Error I am getting is:  </p>
  
  <blockquote>
    <p>UnboundLocalError: local variable referenced before assignment?</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>def menu_option(index, count):
          import random
          random_number1 = random.randrange(1,31)
          random_number2 = random.randrange(1,31)
          if index == 1:
             problem = random_number1 + random_number2
          elif index == 2:
               problem = random_number1 - random_number2
          elif index == 3:
               problem = random_number1 * random_number2
          elif index == 4:
               problem = random_number1 // random_number2
          elif index == 5:
               problem = random_number1 % random_number2
          user_solution = get_user_solution(problem)
          return check_solution(user_solution, solution, count)
  </code></pre>