line#5 must be out of the loop. unindent it one level.
x=[] for n in range(4): y = n ** 2 + 1 x.append(y) print(x)or you can use list comprehension
x = [n ** 2 + 1 for n in range(4)] print(x)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs