title: how to pass variables from one function and use it in another function in Python
body: <p>I have this code:</p>
  
  <pre><code>list1= [1,2,3,4]
  
  
  def get_list():
      for i in list1:
          return i
  
  
  def function_1():
      print(i + int(3))
  
  
  function_1()
  </code></pre>
  
  <p>I try to pass the variable to another function and use it!</p>
  
  <p>I get this error:</p>
  
  <pre><code>NameError: name 'i' is not defined
  </code></pre>
  
  <p>any idea( I dont want to use global)</p>
  
  <p>Maybe this one is a better example:</p>
  
  <pre><code>def func1():
    a=8
    b=9
    return a,b
  
  def func2():
    z=a+b
    return z 
  
  print(z)
  </code></pre>