Exercise 17: Extra symbols added into written file

I probably spent over two hours debugging my question and I am now scratching my head. Any idea why the highlighted symbols keep popping up whenever I do exercise 17? To make sure its not my typing, I have copied and pasted the code from the PDF into Atom and I am still getting the same symbols.

Capture

For Exercise 17 Study Drill 2 challenge are there any faults with the following code:

open(to_file, ‘w’).write(open(from_file).read())

Thanks

Hello @Zago

Could this be the problem
(see the line below)?

open(to_file, ‘w’).write(open(from_file).read())

I could not get that working.
This works for me:

out_file = open(to_file, ‘w’)
out_file.write(indata)

First I create a variable “out_file” and give it the value:

open(to_file, ‘w’) # with permision to write to file.

Then assign it to the write() function:

out_file.write(indata)

I have no idea why you get those character at the end.
It seems that your program runs anyway.

In Powershell there is a default Windows character codec that sets PowerShell to use utf-8 or utf-16 (or something other than ASCII) on file output. All you have to do is delete that file then make it with your text editor rather than using the echo technique.