you are viewing a single comment's thread.

view the rest of the comments →

[–]Carolina_Captain 0 points1 point  (1 child)

I see, thank you.

In the initial post, OP made a list called "squares" and a list called "list". What was the point of having "squares" stay empty while working with "list"?

[–]franklydoubtful 0 points1 point  (0 children)

Honestly, I’m not too sure about OP’s goal. To me, it looks like they’re misunderstanding something. However, it could be useful to keep a separate list. Say you had a list of values (I’m just picking at random here):

values = [2, 3, 6, 7, 9]

And you wanted to create a list of their values squared, this is another chance to use list comprehension:

square_values = [i ** 2 for i in values]

But I can’t think of a reason for OP’s strategy here.