Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python while loop break

import random

# This loop will run forever unless we break it
while True:
    # Generate a random int between 1 and 10
    random_integer = random.randint(1, 10)
    print(random_integer)
    # Stop the loop if the random int is 5
    if random_integer == 5:
        break
Source by pythonhow.com #
 
PREVIOUS NEXT
Tagged: #python #loop #break
ADD COMMENT
Topic
Name
6+2 =