STEP 16: Before we update our new file in update_high_scores(), we first need to open it.

If we change open()'s second parameter to "w", we can open a file in write mode, which allows us to edit it.

If you open a file that doesn't exist in write mode, Python creates that new file for you.

  • In SUBJECT, click on and drag Open in Write Mode inside update_high_scores().
  • Then, change the string "my_file.txt" to the variable file_name.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)