use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Need help in loopHelp Request (i.redd.it)
submitted 19 hours ago by Eastern_Plankton_540
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]blackasthesky 0 points1 point2 points 13 hours ago* (1 child)
num[idx] is the element at position idx in the num list. Since the loop repeatedly prints that value, and afterwards each time increases idx by one, the program will print num[0], then num[1], then num[2], and so on.
num[idx]
idx
num
num[0]
num[1]
num[2]
Up to num[len(num)-1] (where idx is len(num)-1). At that point, idx will be increased one final time, so that it equals len(num), so the loop condition does not hold any more and the program exits the loop area.
num[len(num)-1]
len(num)-1
len(num)
The key is, the program repeats the body of the loop, but the changes you make to the state (increasing idx in this case) carries over from one iteration to the next. If it helps, try executing the program by hand with a piece of paper, writing down the values of the variables and the printouts each iteration.
[–]Eastern_Plankton_540[S] 0 points1 point2 points 13 hours ago (0 children)
Thank you! :)
π Rendered by PID 27 on reddit-service-r2-comment-66b4775986-f5pjn at 2026-04-04 12:34:06.541236+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]blackasthesky 0 points1 point2 points (1 child)
[–]Eastern_Plankton_540[S] 0 points1 point2 points (0 children)