How to define WHILE Loop in Python?
0

How to define WHILE Loop in Python?

This recipe helps you define WHILE Loop in Python
In [1]:
## How to define WHILE Loop in Python
def Kickstarter_Example_59():
    print()
    print(format('How to define WHILE Loop in Python','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # Load Libraries
    import random

    # Create a variable of the true number of Sales of a Retail event
    sales = 7

    # Create a variable that is denotes if the while loop should keep running
    running = True

    # while running is True
    while running:
        # Create a variable that randomly create a integer between 0 and 10.
        guess = random.randint(0,10)

        # if guess equals number of sales,
        if guess == sales:
            print('Correct!')
            running = False

        # else if guess is lower than slaes
        elif guess < sales:
            print('No, it is higher.')
        else:
            print('No, it is lower')

Kickstarter_Example_59()
************************How to define WHILE Loop in Python************************
No, it is lower
No, it is lower
No, it is lower
Correct!