Is there a way to open a file in both read and write?

Having gone through the whole lesson, I didn’t come across a way of opening a file in both ‘read’ and ‘write’ mode (I might have missed something). Is there such a way?

if you check the documentation:

https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files

you will see this mode exist. there is read ®, write (w), append (a) and read + write (r+)

4 Likes

Grand, thank you! I was on that page but clearly didn’t read it through…