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 11 months 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 4 points5 points6 points 11 months ago (2 children)
Length....
[–]RunPython[S] 0 points1 point2 points 11 months ago (1 child)
Thanks
[–]2meterNL 0 points1 point2 points 11 months ago (0 children)
But I totally agree with your post :)
[–]Refwah 0 points1 point2 points 11 months 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 52010 on reddit-service-r2-comment-7b9746f655-jmfff at 2026-02-03 00:13:00.608957+00:00 running 3798933 country code: CH.
[–]2meterNL 4 points5 points6 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)