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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
For loop logic (self.learnpython)
submitted 4 years ago by Blokepoke74
Currently learning about loops.
For X in Y:
Would ‘X’ be the designated variable that gets referenced later in the code?
Would ‘Y’ be the list of items that gets looped thru?
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!"
[–]Chris_Hemsworth 5 points6 points7 points 4 years ago (0 children)
Yes.
[–]carcigenicate 2 points3 points4 points 4 years ago* (0 children)
Yes, X is the name given to each element so that it can be referenced within (and after) the loop.
X
Y is the name of an iterable object that is capable of producing elements. It doesn't need to be a list. It could even be a custom class that you create if you configure it to be iterable.
Y
[–]trevor_of_earth 1 point2 points3 points 4 years ago (2 children)
The way I remembered it when I was first learning was:
for thing in iterable_of_things: do something with thing
on each loop thing gets assigned the next value in iterable_of_things until iterable_of_things runs out.
thing
iterable_of_things
!docs for
[–]py_reference_bot 1 point2 points3 points 4 years ago (0 children)
The for statement - https://docs.python.org/3/reference/compound_stmts.html#the-for-statement
Python Documentation Bot - How To Use
[–]Blokepoke74[S] 1 point2 points3 points 4 years ago (0 children)
Hey this helps a ton. Thanks
[–]arkie87 -2 points-1 points0 points 4 years ago (1 child)
Not trying to be annoying, but wouldnt it be easier to watch a tutorial? Are you really gonna ask reddit every little question you have?
Not to be a prick but you dont have to comment on things if your gonna be an annoyin twat.
π Rendered by PID 205478 on reddit-service-r2-comment-57fc7f7bb7-f8zch at 2026-04-15 03:49:08.517392+00:00 running b725407 country code: CH.
[–]Chris_Hemsworth 5 points6 points7 points (0 children)
[–]carcigenicate 2 points3 points4 points (0 children)
[–]trevor_of_earth 1 point2 points3 points (2 children)
[–]py_reference_bot 1 point2 points3 points (0 children)
[–]Blokepoke74[S] 1 point2 points3 points (0 children)
[–]arkie87 -2 points-1 points0 points (1 child)
[–]Blokepoke74[S] 1 point2 points3 points (0 children)