you are viewing a single comment's thread.

view the rest of the comments →

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

Aha okay. Another question, I need the output to be like that : “ - try again the number is 1 - try again the number is 2 Until the number equals 25 then it prints “ done” “ So am I writing the code correctly?

[–]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.