Ex 17: Type Error

How can I remove this error? I wanted to print the contents of the file over which I used the write() method. I read that after committing changes using write() method the changes need to be saved, one of the ways to save it is, by calling close() function on the file. I did that, but still not able to print it.

I now know where it went wrong! I was passing TextIOWrapper to open() function as args, when it takes filename or file destination as args!

2 Likes

Nice, can I ask why you’re doing this all on one line?

There was a task in the Study Drill where you wrote “I could write this in one line”. So was just playing with semi-colon.

Thought so. Just write the code like normal on multiple lines, then join all of the lines together with a ; and you’re done. :wink:

1 Like
A free service run by Zed A. Shaw for learncodethehardway.org.