title: Using variables from other functions in Python
body: <p>I am learning python and am currently writing a simple program that has to be divided into functions. My problem is that I have one function that should return strings for four different variables, that then should be used in another function.</p>
  
  <p>E.g.</p>
  
  <pre><code>def function1():
     var1 = input("Write something: ")
     var2 = input("Write something: ")
     var3 = input("Write something: ")
  
  def function2():
     print(var1)
     print(var2)
     print(var3)
  
  function1()
  function2()
  </code></pre>
  
  <p>This gives an error message since var1 is not defined in the frame of function2. How should this be solved? The illustration is very simplified for clarity, but I could post something more specific if required.</p>