Exercise 20. Functions and Files


#1

I’m working through the book for python 3 and I can’t work out what’s gone wrong in ex20. I’ve written the code out myself, checked it, and even gone back and copied the code out of the book and pasted it into my editor and the same problem persists, so I know it isn’t an issue with my code. I’m running python 3.7 and I’ve checked that powershell is running that correctly so I don’t know what else to try. Does anyone know what’s gone wrong here? My powershell output is in the image attached. It only let me upload one image but the text file simply read:
“has
this
worked?”
.


#2

Hey , copy all the code here so we can see. Don’t forget to wrap it in <code><\code> tags.
The output will be like this.


#3

Hey @willharris, I deleted your post with the code as the answer is easy:

When you made the file in PowerShell you probably didn’t use your text editor like Atom or similar. Windows, in its infinite stupidity, will default to creating a utf-16 or utf-8 file, but can’t display those files when you output them. So, just delete your test.txt totally. Then use Visual Studio Code or Atom to recreate it.