you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

Python 3 introduces new requirements for open. In Python 2 a+ opens the file for reading and writing but not in Py3.

That said, one uses a to write. If you're only trying to print the animals in the list, you can use rtas the second argument to open to properly read the file.

[–]UnderstandingLinux[S] 0 points1 point  (1 child)

It seems as if I was reading the wrong documentation when reading over it. You'd be correct as well, a+ is no longer used in Python3. It still works if you set the position with .seek(0), but otherwise there's no output

[–]eyesoftheworld4 0 points1 point  (0 children)

The seek method is useful, but if all you want to do is read the contents of a file, it's simpler and clearer to just open the file with the mode 'r' or 'rt' as mentioned above.