Preferably something that explains the answer below (without the spaces)
0
1
4
9
16
Preferably something that explains the answer below (without the spaces)
0
1
4
9
16
You can use list comprehension for this much more idiomatic question:
[ i**2 for i in range(5) ]
If you want something that manages this result you showed in the question, just do this:
i = 0
lista=[]
while i < 5:
lista.append((i ** 2))
i += 1
Output:
[0, 1, 4, 9, 16]
and so on.