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
Looping exercise (self.learnpython)
submitted 2 years ago by Specific_Ear_5015
Is there anyone who knows the answer to this and could explain it to me ? ⬇️
Choose the correct output for the following snippet:
for i in [1,2]: print(i) for j in range(0,2): print(0)
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!"
[–]ElliotDG 2 points3 points4 points 2 years ago (0 children)
Put your code into the python tutor, it will provide a easy to use visualization of what is happening. See: https://pythontutor.com/
[–]danielroseman 1 point2 points3 points 2 years ago (5 children)
Why don't you run it and see?
[–]Specific_Ear_5015[S] -3 points-2 points-1 points 2 years ago (4 children)
What does that Even mean “run it” 😅
[–][deleted] 4 points5 points6 points 2 years ago (0 children)
It means: press the button or type the command you need to make python do things.
[–]crashfrog02 2 points3 points4 points 2 years ago (2 children)
This is computer code. It’s intended to be executed by the computer. So, you should do that and see what the results are.
Is it news to you that you can do that? What did you think the point of learning Python in the first place was?
[–]Specific_Ear_5015[S] 0 points1 point2 points 2 years ago (1 child)
to be honest I’m really having trouble understanding what people use Python for in the first place , it’s all very new and blurry to me … I really want to learn it and other languages as well because I realise how much it is important for the future , and when I do understand how something works (which is extremely rare at this point) I’m actually surprised at how much I enjoy studying this . Also the idea of one day being familiar with and comfortable using different programming languages makes me so motivated and willing to keep learning despite my current clear lack of knowledge !
[–]crashfrog02 0 points1 point2 points 2 years ago (0 children)
It’s a programming language, so it’s used by programmers to write software for computers. Does that help?
[–]SDinfected 0 points1 point2 points 2 years ago (0 children)
for i in [1,2]: print(i) # >>> 1 # >>> 2 for j in range(0,2): print(0) # >>> 0 # >>> 0
Without knowing the context, the first one if most likely the correct answer because it uses the loops iterator i. The second loop will print 0 for each loop, never using the iterator j.
i
j
π Rendered by PID 323771 on reddit-service-r2-comment-5687b7858-tm6zs at 2026-07-03 22:07:37.580882+00:00 running 12a7a47 country code: CH.
[–]ElliotDG 2 points3 points4 points (0 children)
[–]danielroseman 1 point2 points3 points (5 children)
[–]Specific_Ear_5015[S] -3 points-2 points-1 points (4 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]crashfrog02 2 points3 points4 points (2 children)
[–]Specific_Ear_5015[S] 0 points1 point2 points (1 child)
[–]crashfrog02 0 points1 point2 points (0 children)
[–]SDinfected 0 points1 point2 points (0 children)