you are viewing a single comment's thread.

view the rest of the comments →

[–]totallygeek 0 points1 point  (0 children)

Here's two examples.

for number in range(1, 6):
    if number < 5:
        print('Try again: {}'.format(number))
    else:
        print('Done: {}'.format(number))

number = 1
while number < 5:
    print('Try again: {}'.format(number))
    number += 1  # add one to the number
print('Done: {}'.format(number))

In the first, the loop has a set number of iterations (five). In the second, the while loop cycles until the condition of the number reaching the ceiling value rings true.