title: Error handing with passing variables through functions that are yet to be defined through user error
body: <p>I am building a menu that performs visualizations from an inputted DF through pandas. Via the menu, the first option selects 'load data' and from there I have a number of menu options that clean the loaded data, perform analytics etc.
  Now if the data is yet to be loaded, how do I avoid the NameError if a user selects clean data before they have loaded the data?</p>
  <pre class="lang-py prettyprint-override"><code>print(menu)
  menu_choice = input(&quot;&gt;&gt;&gt; &quot;)
  while menu_choice != '7':
      if menu_choice == '1':
          load_data()
      elif menu_choice == '2':
          view_data(data)
      elif menu_choice == '3':
          clean_data(data)
      elif menu_choice == '4':
          analyse_data(data)
      elif menu_choice == '5':
          visualise_data(data)
      elif menu_choice == '6':
          save_data(data)
      else:
          print(&quot;Invalid option!&quot;)
      print(menu)
      menu_choice = input(&quot;&gt;&gt;&gt; &quot;)
  if menu_choice == '7':
      print(&quot;Goodbye!&quot;)
  </code></pre>
  <p>under load_data it will produce a data frame called 'data' if you were wondering where data came from.</p>
  <p>So if someone is yet to select option 1, how do I handle the error if they select option 3 first?</p>