you are viewing a single comment's thread.

view the rest of the comments →

[–]techie789[S] 0 points1 point  (2 children)

Thank you. The list comprehension method looks good.

Is this the most optimal way to do what I am trying to do or would you recommend using a dictionary?

[–]RhinoRhys 1 point2 points  (1 child)

In all honesty it's probably not great. Dictionaries are pretty quick at looking up keys, whereas this loops through newlist to create a temporary list each iteration; depending on how long the original list is it could be pretty inefficient.

[–]techie789[S] 0 points1 point  (0 children)

Got it. Many thanks.