title: How to avoid using global variables?
body: <p>I use global variables but I've read that they aren't a good practice or pythonic. I often use functions that give as a result many yes/no variables that I need to use in the main function. For example, how can I write the following code without using global variables?</p>
  <pre><code>def secondary_function():
      global alfa_is_higher_than_12
      global beta_is_higher_than_12
  
      alfa = 12
      beta = 5
  
      if alfa &gt; 10:
          alfa_is_higher_than_12 = &quot;yes&quot;
      else:
          alfa_is_higher_than_12 = &quot;no&quot;
  
      if beta &gt; 10:
          beta_is_higher_than_12 = &quot;yes&quot;
      else:
          beta_is_higher_than_12 = &quot;no&quot;
  
  def main_function():
      global alfa_is_higher_than_12
      global beta_is_higher_than_12
  
      secondary_function()
  
      if alfa_is_higher_than_12==&quot;yes&quot;:
          print(&quot;alfa is higher than 12&quot;)
      else:
          print(&quot;alfa isn't higher than 12&quot;)
  
      if beta_is_higher_than_12==&quot;yes&quot;:
          print(&quot;beta is higher than 12&quot;)
      else:
          print(&quot;beta isn't higher thant 12&quot;)
  
  main_function()
  </code></pre>