title: Create a file if it doesn't exist
body: <p>I'm trying to open a file, and if the file doesn't exist, I need to create it and open it for writing. I have this so far:</p>
  
  <pre><code>#open file for reading
  fn = input("Enter file to open: ")
  fh = open(fn,'r')
  # if file does not exist, create it
  if (!fh) 
  fh = open ( fh, "w")
  </code></pre>
  
  <p>The error message says there's an issue on the line <code>if(!fh)</code>. Can I use <code>exist</code> like in Perl?</p>