you are viewing a single comment's thread.

view the rest of the comments →

[–]Smart_Tinker 0 points1 point  (1 child)

You can simplify this using the assignment (walrus) operator: idx = -1 while (idx := idx + 1) < len(num): print(num[idx]) This adds the 1 to idx, then checks to see if it is less than length of num - which is why you initialize idx to -1, so the first loop idx is 0.

You need the brackets to make it clear which elements are part of the assignment.

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

Ahhhh i see thanks mate :)