While Loops

1 / 5

A while loop allows code to be repeated as long as a Boolean condition is true. For example, to print numbers from 1 to 5, you can use:

count = 1
while count <= 5:
    print(count)
    count = count + 1

This loop continues until count exceeds 5. The indentation is crucial, as it defines which lines are repeated.

Simple while loops

Input an integer n. Generate a string s of n asterisks (*) and print s.

For example, if n is 5, print *****.

Congratulations!

You passed the !

Welcome!

Would you like a guided tour on how to use Vibewise?

Your email has been verified!