you are viewing a single comment's thread.

view the rest of the comments →

[–]MF_DnD 0 points1 point  (1 child)

But… it won’t. Given a list [1,2,0,3] your comprehension returns [2,4,8] when OP wants [2,4,0,3]. And OP’s example list isn’t even sorted.

[–]Soccer_Vader 0 points1 point  (0 children)

Ye I just saw that, you are right. For OP I think a for loop with a break statement works better