I need help with Python. 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:
#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")
The error message says there's an issue on the line if(!fh). Can I use exist like in Perl?