$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #213

Which fix removes the bug?

with open('out.txt') as f:
    f.write('hi')
  1. Call f.flush() first
  2. Use f.print() to write
  3. Open it with mode 'w'
  4. Open it with mode 'r'
open() defaults to read mode, so write() raises io.UnsupportedOperation.
Play Problem Solving ▸