Permission denied error while writing to a file in Python

python

Solution

Please close the file if its still open on your computer, then try running the python code. I hope it works

Problem

I want to create a file and write some integer data to it in python. For example, I have a variable abc = 3 and I am trying to write it to a file (which doesn't exist and I assume python will create it on its own): ``` fout = open("newfile.dat", "w") fout.write(abc) ``` First, will python create a newfile.dat on its own? Secondly, it's giving me this error: ``` IOError: [Errno 13] Permission denied: 'newfile.dat' ``` What's wrong here?

Original source

Related problems