title: How do I create a text file from user input in python?
body: <p>In my program the user is asked for their Name, Surname and High School Class. At the the end of the program there is an if statement and if the condition is met then I would like to create a file which will print these variables as well as a message or two. </p>
  
  <p>I would also like to ask the user to enter a short statement about themselves so basically a text entry and this is to be added to the file also.</p>
  
  <pre><code>class Score_Window(tk.Toplevel):
  '''A simple instruction window'''
  def __init__(self, parent):
      tk.Toplevel.__init__(self, parent)
      score_str = str(sum(parent.score_per_question.values()))
      self.score = tk.Label(self, width=80, height=4, text = "You're score was: " + score_str)
      self.score.pack(side="top", fill="both", expand=True)
  
  
      if int(score_str) &gt;= 3:
          print("Pass")
  
          self.prefect = tk.Label(self, width=80, height=4, text = "You have passed, well done! You can now become a prefect.")
          self.prefect.pack(side="top", fill="both", expand=True)
  
          self.name = tk.Label(self, width=80, height=4, text = student_name)
          self.name.pack(side="top", fill="both", expand=True)
  
          self.surname = tk.Label(self, width=80, height=4, text = student_surname)
          self.surname.pack(side="top", fill="both", expand=True)
  
          self.tutor = tk.Label(self, width=80, height=4, text = student_tutor_group)
          self.tutor.pack(side="top", fill="both", expand=True)
  </code></pre>
  
  <h1>I want to print these variables to a file</h1>
  
  <pre><code>    else:
          print("Fail")
  
          self.fail = tk.Label(self, width=80, height=4, text = "Unfortunately you have not scored highly enough to be considered for a prefect position.")
          self.fail.pack(side="top", fill="both", expand=True)
  </code></pre>