title: Need help creating a txt log file in Python
body: <p>I am stuck on an assignment:  We have to make a password checker with a txt log file logging the time and date a password was put it, but only if the password doesn't meet the requirements to be accepted.</p>
  
  <p>The password checker code is below, I need some help with logging to a file.</p>
  
  <pre class="lang-py prettyprint-override"><code>PASSWORD_MIN_LENGTH = 6
  PASSWORD_MAX_LENGTH = 14
  
  password = input("Enter your password: ")
  
  password_length = len(password)
  
  while password_length &lt; PASSWORD_MIN_LENGTH or password_length &gt; PASSWORD_MAX_LENGTH:
      print("Error - password out of range")
      password = input("Enter new password between 6 and 14 characters: ")
      password_length = len(password)
  
  if password.isdigit():
      message = "your password is too weak"
  elif password.isalpha():
      message = "your password is too weak"
  else:
      message = "your password is strong"
  
  print(f"{message} your password length was: {password_length}")
  </code></pre>
  
  <p>Any suggestions?</p>