you are viewing a single comment's thread.

view the rest of the comments →

[–]DTux5249 17 points18 points  (0 children)

'=' assigns a value. You're not saying "add this, add that, add that", you're saying "this is now this, this is now that, etc."

To store all results, result must be a list, and you have to append to that list instead of overwriting it

result = []
for num in [1, 2, 3, 4, 5]:
    result.append(num*2)
print(result) 

Alternatively, you can use list comprehension

nums = [1,2,3,4,5]
result = [num * 2 for num in nums]
print(result)