This is my first time with I/O files. I have "commented" on every line as I understand it. I guessed r is for read. Are my comments correct or can they be improved. Why str/item in line 8? Thank you all.
my_list = [i**2 for i in range(1,11)] # Generates a list of squares of the numbers 1 - 10 f = open("output.txt", "w") #(# "w" for write mode on to selected file output.txt, "r" for read mode, ) for item in my_list: #select each item/number and square it f.write(str(item) + "\n") #( write/output on to the file we have opened/selected, "\n" next line, str(item???) f.close() #close fileReplace this line with your code.