title: Python Error - UnboundLocalError: local variable referenced before assignment
body: <p>My issue:
  In my program I have a function which is only supposed to run when the user has inputed several values which are then kept in a dictionary. My initial idea was in the function to get the length of the dictionary and if it was 0 (meaning it was empty) that would be a sign the values haven't been inputed. However when I run the code I get this error 'UnboundLocalError: local variable 'dictionary' referenced before assignment'. On the other hand though when length is more than 1 (the values have been entered) the code runs perfectly. The relevant code is as follows;</p>
  
  <pre><code>def displayValues(data):
      if len(data) == 0:
          print('No Values Found - Please Enter Values')
          Main()
      elif len(data) != 0:
          print()
          print('-'*77)
          for key,value in sorted(data.items()):
              print(key,':',value)
              print('-'*77)
          time.sleep(5)
          print()
  
  def Main():
      while True:
          choice = displayMenu()
          if choice == 1:
              dictionary = setValues()
          elif choice == 2:
              displayValues(dictionary)
          elif choice == 3:
              runModel(dictionary)
          elif choice == 4:
              exportData()
          elif choice == 5:
              quit()
  
  Main()
  </code></pre>
  
  <p>Please note I am sure the setValues() function which returns the values saved in the dictionary variable is functioning as if the case is that the len of the dictionary is not 0 the code works fine. Also I have not used the variable name 'dictionary' anywhere else in the code therefore it is not being repeated.
  Any possible ideas of where I am going wrong would be appreciated? Thanks</p>