Hey, I'm having some issues with 3. Writing.
I think I know how it works, it's a pretty easy one.
However after 3 attemps I can't get the output right.
Output.txt looks like this:
and the code itself looks like this:
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" % (i)) my_file.close()
I also tried
for i in my_list: my_file.write(str(i) + "\n")
But that gave me the exact same results.
And one more thing, I tried it about 3/4 times and I never changed line 3, but it now gives an error:
Traceback (most recent call last): File "python", line 3, in <module> IOError: [Errno 2] No such file or directory: 'output.txt'
This error happens with both variations of the code. So now every time I make a change I don't know if my change isn't adequate, or this site or my browser is just bugging out a bit. Because I didn't change anything when that error started happening.
I can continue by the way. When I didn't get the error I couldn't complete it because output.txt was wrong.
When I got the error it ignored output.txt being wrong.