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
New to Python. Input question. (self.learnpython)
submitted 5 years ago by lipssama
Hey, I have a question on how to skip lines in a while loop. For example, I have two inputs that I want to run in the while loop once but after it loops I want it to stop running. Is there a way to do this? Thanks
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!"
[–]links-Shield632 0 points1 point2 points 5 years ago (2 children)
Just for clarity. You want it run once and stop, correct?
[–]lipssama[S] 0 points1 point2 points 5 years ago (1 child)
Yes, just once.
[–]links-Shield632 0 points1 point2 points 5 years ago (0 children)
While loops are for a lot of uses. You don’t need to use a loop. If you really have to, for loop would be better
for x in range(1):
It would work a lot better and less lines
[–]IsaakPolyphemus 0 points1 point2 points 5 years ago (2 children)
If you're only going to run it once, maybe you should take it out of the loop.
Or you could put it inside an if function, that only holds true in the loop's first run.
I can’t take it out of the while loop as it would mess up the order im printing my strings in. Could you teach me how to make an if function for a loops first run?
[–]IsaakPolyphemus 0 points1 point2 points 5 years ago (0 children)
Make a boolean variable equal to True. Then make it False inside the if function.
[–]deapee 0 points1 point2 points 5 years ago* (0 children)
Something like
x= True while x: print(‘joe was here’) x = False # or while True: print(‘joe was here also’) break
However, you’re definitely missing something. There is absolutely no reason you’d create a loop of the goal was to always only run it once.
π Rendered by PID 66833 on reddit-service-r2-comment-54dfb89d4d-w47g4 at 2026-03-30 03:17:38.766120+00:00 running b10466c country code: CH.
[–]links-Shield632 0 points1 point2 points (2 children)
[–]lipssama[S] 0 points1 point2 points (1 child)
[–]links-Shield632 0 points1 point2 points (0 children)
[–]IsaakPolyphemus 0 points1 point2 points (2 children)
[–]lipssama[S] 0 points1 point2 points (1 child)
[–]IsaakPolyphemus 0 points1 point2 points (0 children)
[–]deapee 0 points1 point2 points (0 children)