Writing


#1


Allows me to go to the next lesson but I have the following error on the console, and don't see anything being written on the file tab:
Traceback (most recent call last):
File "python", line 3, in
IOError: [Errno 2] No such file or directory: 'output.txt'

Is that a correct way of doing this exercise?


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(my_list[i].str()) 
    print "\n"

my_file.close()


#2

If you passed, that means you're correct. Codecademy isn't too good with Python's input/output right now.

What I did to make my output.txt show is to go to that tab, type some random things there, delete them and hit Save&Submit (it may take several tries).

You can check by testing it outside of Codecademy (get Python :D).


#3

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