3. Writing


#1



3. Writing


I try to save & submit, but it tells me that there is an error with the syntax. The terminal pops up with:

File "python", line 9
my_file.close()
^
SyntaxError: invalid syntax


I have tried logging out, shutting down, and trying again later to no avail. Beyond frustrating.


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()


#2

Well that's embarassing... missed a bracket. Why would it tell me that the syntax is toast at the close command though?


#3

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