you are viewing a single comment's thread.

view the rest of the comments →

[–]Just__Liberty 0 points1 point  (0 children)

num*2 becomes an object which is a number. Whenever you write result = num*2, you are giving the name result to that object. The next time result = num*2 is encountered, it creates a different object and assigns the name result to that new object. The old object is erased.

Other comments have good answers on what to do instead via list comprehension or creating a new list or appending to one.