Which fix removes the bug?
with open('out.txt') as f:
f.write('hi')
- Call
f.flush()first - Use
f.print()to write - Open it with mode
'w' - Open it with mode
'r'
open() defaults to read mode, so write() raises io.UnsupportedOperation.
Play Problem Solving ▸