I am trying to write a program that creates a file (if it doesn't exists yet) and then writes a text in it. My code looks like
with open(("test_program/files/{}.txt").format("houses"), 'w+') as f:
w = csv.writer(f)
w.writerow([('This is the file with houses')])
But I get the error
FileNotFoundError: [Errno 2] No such file or directory: 'test_program/files/houses.txt'
I am using python 3.6