Why is my list not updating when I use append inside a loop in Python?

2 weeks ago 13
ARTICLE AD BOX

I’m trying to add numbers to a list using a loop:

nums = [] for i in range(5): nums.append(i * 2) print(nums)

But the list prints [] instead of values.
Am I missing something basic?
How can I correctly append elements to a list?

Read Entire Article