Writing Error- I don't get it


#1


https://www.codecademy.com/courses/python-intermediate-en-OGNHh/0/3?curriculum_id=4f89dab3d788890003000096#


I don't really get the error in this script. The error is 'Oops, try again. It looks like your file doesn't contain each element from my_list on its own line.' Please help somebody! Thanks in advance!


my_list = [i**2 for i in range(1,11)]

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

for i in my_list:
    my_file.write(str(i))
my_file.close()


#2

Writing some formatted text should help...

"%s\n" % i

Note that we include the newline escape sequence.


#3

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