SOMEONE HELP ME... Code Won't work. All help is appreciated


#1



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


Error Message: It looks like your file doesn't contain each element from my_list on its own line


I expected this code to work, can someone explain why the console won't accept this. It says that 'your file doesn't contain each element from my_list on its own line' when it does...


Replace this line with your code. 
my_list = [i**2 for i in range(1,11)]

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

# Add your code below!
for item in my_list:
    print str(item)
    my_file.write("item"),
    my_file.write("\n")
my_file.close()


#2

The code checker is expecting you to use the '\n' as the line-terminator !!!


#3

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