I am currently stuck on WRITING, Under File Input/Output, Python.

My code exactly is:

my_list = [i**2 for i in range(1,11)]

my_file = open("output.txt", "r+")

Add your code below!

for item in my_list:
my_file.write(str(item) + "\n")

It then reads:
"Oops, try again. It looks like your file doesn't contain each element from my_list on its own line."


As your code is not formatted It's hard to tell what's the problem,
But Its surely looks "wrong indentation" ,
Check indentation of program.
check your last line of program,make sure that its a separate block of code and It should have same indentation level as for loop.

if code is correct,refresh and submit again!


Thank you my friend, Extremely helpful. Was stuck on that section for close to an hour.
Kind regards,
BAGATOV, Azamat.


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