Writing


#1



What's Wrong Please Help


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:
    my_file.write("%s \n" % str(i))

my_file.close()


Writing
#2

Hi, @cloudace57488 ,

What error message are you getting? That should be helpful for remedying the problem.


#3



Is he answer supposed to be a syntax error


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:
    my_file.write("%s \n" % str(i))

my_file.close()


#4

No, the correct solution should not produce a SyntaxError. What specific type of error or Codecademy message are you getting when you submit the code?

Which exercise is this? Please provide a link to it.


#5

Hi,

If you change r+ to w in the open method, it will pass.


#6

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