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?
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?
Hidden in mobile, Best for skyscrapers.