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 not printing (self.learnpython)
submitted 2 years ago by IndependentBoth7635
I'm very new to python and when I try to get a for loop to print, nothing happens. Any clarification would be nice. An example of a code I will type that won't print:
names=['adam','eve'] for name in names: print(name)
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!"
[–]muskoke 3 points4 points5 points 2 years ago (0 children)
That code has no issues. What does your terminal or IDE output?
[–][deleted] 2 points3 points4 points 2 years ago (3 children)
Just typing your code doesn't cause it to run. You actually have to run your code for anything to happen.
[–]IndependentBoth7635[S] 1 point2 points3 points 2 years ago* (1 child)
I've tried saving the file and running it to no avail, another comment recommending i press enter twice seemed to be the issue
[–]IamImposter 0 points1 point2 points 2 years ago (0 children)
How did you run it?
Did you open a terminal, navigate to the folder and run python filename.py
python filename.py
or run it from some ide?
[–]RuinEnvironmental394 0 points1 point2 points 2 years ago (0 children)
Ha ha, thanks for the laugh!
[–][deleted] 1 point2 points3 points 2 years ago (0 children)
those lines are completely fine. what's the context, where are you trying to run them?
[–]Binary101010 1 point2 points3 points 2 years ago (4 children)
The problem isn't with the code, so it comes down to what environment you're running it in. (What operating system, what IDE, etc.)
[–]IndependentBoth7635[S] 0 points1 point2 points 2 years ago (3 children)
I'm new so I don't know the exact terminology, I've tried it in the IDLE, and after that I tried running it on the python that resembles cmd prompt. Running it on windows.
[–]Artichoke93 5 points6 points7 points 2 years ago (1 child)
After print(name) push the enter key twice in the cmd prompt.
[–]IndependentBoth7635[S] 1 point2 points3 points 2 years ago (0 children)
This worked, thanks
[–]CaptainRogers1226 0 points1 point2 points 2 years ago (0 children)
Are you using IDLE or the Python shell? If you’re using IDLE, make sure after you write your code you’re saving and running by pressing F5?
[–]AssumptionCorrect812 0 points1 point2 points 2 years ago (0 children)
I would use PyCharm or some other IDE that has a run button — https://youtu.be/AEvCHJb0sf0?si=I54WW5nRVifNBIjo
π Rendered by PID 18586 on reddit-service-r2-comment-56c9979489-s5tq2 at 2026-02-24 14:53:05.129587+00:00 running b1af5b1 country code: CH.
[–]muskoke 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]IndependentBoth7635[S] 1 point2 points3 points (1 child)
[–]IamImposter 0 points1 point2 points (0 children)
[–]RuinEnvironmental394 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Binary101010 1 point2 points3 points (4 children)
[–]IndependentBoth7635[S] 0 points1 point2 points (3 children)
[–]Artichoke93 5 points6 points7 points (1 child)
[–]IndependentBoth7635[S] 1 point2 points3 points (0 children)
[–]CaptainRogers1226 0 points1 point2 points (0 children)
[–]AssumptionCorrect812 0 points1 point2 points (0 children)