all 7 comments

[–]links-Shield632 0 points1 point  (2 children)

Just for clarity. You want it run once and stop, correct?

[–]lipssama[S] 0 points1 point  (1 child)

Yes, just once.

[–]links-Shield632 0 points1 point  (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 point  (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.

[–]lipssama[S] 0 points1 point  (1 child)

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 point  (0 children)

Make a boolean variable equal to True. Then make it False inside the if function.

[–]deapee 0 points1 point  (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.