title: How can I share a variable between functions in Python?
body: <p>I have two functions, <code>fun1</code> and <code>fun2</code>, which take as inputs a string and a number, respectively. They also both get the same variable, <code>a</code>, as input. This is the code:</p>
  <pre><code>a = ['A','X','R','N','L']
  
  def fun1(string,vect):
      out = []
      for letter in vect:
          out. append(string+letter)
      return out
  
  def fun2(number,vect):
      out = []
      for letter in vect:
          out.append(str(number)+letter)
      return out
  
  x = fun1('Hello ',a)
  y = fun2(2,a)
  </code></pre>
  <p>The functions perform some nonsense operations. My goal would be to rewrite the code in such a way that the variable <code>a</code> is shared between the functions, so that they do not take it as input anymore.</p>
  <p>One way to remove variable <code>a</code> as input would be by defining it within the functions themselves, but unfortunately that is not very elegant.
  What is a possible way to reach my goal?</p>
  <p>The functions should operate in the same way, but the input arguments should only be the string and the number (<code>fun1(string)</code>, <code>fun2(number)</code>).</p>