Reputation: 21
I want to run 1 time ONLY in while loop.
while True:
print("Hello World")#this word always print
print("HI")#this word print 1 time only
Upvotes: 1
Views: 1797
Reputation: 1306
Just add a validation logic to it
x = False
while True:
print("Hello World")
if x == False:
print("HI")
x = True
Upvotes: 2
Reputation: 111
I have no idea what your use case is... but just add a "break" to end the loop.
while True:
print("Hello World")
print("This words should show 1 time")
break
Edit based on your comment...
ran = False
while True:
print("Hello World")
If not ran
print("This words should show 1 time")
ran = True
Upvotes: 3