Some Error in 3/11 - File input/output


Help, I feel like my code is correct but I get the error saying: "Oops, try again. It looks like your file doesn't contain each element from my_list on its own line." Thanks

Replace this line with your code.


This is my code:
my_list = [i**2 for i in range(1,11)]

my_file = open("output.txt", "r+")

Add your code below!

for i in my_list:


use the write option when opening the file. The file doesn't exist yet.


I'm sorry I am new at this, how do I use the write option to open the file?


your code is working fine

see if writing to file works:

my_file = open("output.txt", "w")

otherwise refresh the page


Haha thanks, it worked after I refreshed the page!