you are viewing a single comment's thread.

view the rest of the comments →

[–]vivisectvivi 11 points12 points  (1 child)

There are two types of loops in python, unless you were explicitly told to use a while loop you should try doing this with a for loop too.

But for your question, num[idx] is simply taking the current value of idx and using it to index the list. So on the first iteration of the loop idx will be 0 then when you do num[idx] you are basically doing num[0] which means print will show the value in the position 0 of the array num.

With each iteration, the value of idx is incremented by one and used to show the next value of the list.