title: How to not use global in python
body: <p>My code works using global to define some variables but is there any other way to make them be defined without using global? Otherwise, I run into error's regarding variables not being defined.</p>
  <p>Here is my code:</p>
  <pre><code>#takes list of rows of code, returns dict of alumni and grad year
  def makeAlumniDict():
      global my_dict
      my_dict = {'Charell Adagala': 2018, 'Sukhneet kaur': 2018, 'Mayanka Jha': 2019,
              'Paul Cheakalos': 2018, 'Elizabeth(Liz)Boniface': 2013,
              'Kati Illieva': 2021, 'Suzy wilson': 2018, 'Ronit Gopalani': 2019}
  
  #takes dictionary of alumni and years, returns list of alumni grads between years (inclusive)
  def betweenYears():
      makeAlumniDict()
      
      names = []
      for name, date in my_dict.items():
          if start &lt;= date &lt;= end:
              names.append(name)
      print(names)
      
  
  #MAIN CODE
  def main():
      
      global start
      global end
      start = int(input('Start Year: '))
      end = int(input('End Year: '))
  
  
      betweenYears()
      
  main()
  </code></pre>