Try it yourself


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

https://www.codecademy.com/courses/learn-python/lessons/file-inputoutput/exercises/try-it-yourself?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
I cant figure out what the error is even though the code seems perfect to me

```python

with open(“text.txt”, “w”) as my_file:
my_file.write(“Cheese_S”)

<do not remove the three backticks above>

#2

Check your indenting to ensure that my_file.write("Cheese_S") is under the with..as line of code. As simple way to ensure proper indenting is to do this:

  1. Put your cursor before my_file.write
  2. Backspace until that line of code is inline with the first line of code, meaning it’s up on line 1 just after the colon :
  3. Then press return/enter on your keyboard.

Bam, the editor takes care of indenting it for you.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.