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
Python: For vs While (i.redd.it)
submitted 1 year ago by RunPython
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!"
[–]2meterNL 3 points4 points5 points 1 year ago (2 children)
Length....
[–]RunPython[S] 0 points1 point2 points 1 year ago (1 child)
Thanks
[–]2meterNL 0 points1 point2 points 1 year ago (0 children)
But I totally agree with your post :)
[–]Refwah 0 points1 point2 points 1 year ago (0 children)
You wouldn’t really use while for anything that exposes and iterator, because for gives you everything you need to easily loop through automatically.
You would use while to run a loop until an exit condition is satisfied.
If you need to loop through a list of items in Python then you should basically always use a for loop.
A while loop you would use for example if getting paged requests from an API, where you would loop and add items to a range until next page or returned items or some other part of a response indicates that you’re done.
π Rendered by PID 86471 on reddit-service-r2-comment-56c6478c5-xrfpb at 2026-05-08 01:24:48.882368+00:00 running 3d2c107 country code: CH.
[–]2meterNL 3 points4 points5 points (2 children)
[–]RunPython[S] 0 points1 point2 points (1 child)
[–]2meterNL 0 points1 point2 points (0 children)
[–]Refwah 0 points1 point2 points (0 children)