This lesson requires a premium membership to access.
Premium membership includes unlimited access to all courses, quizzes, downloadable resources, and future content updates.
The general format of the while statement is:
1while (condition) :
2 statement
3}
4Note that a while loop may never execute the statement. The statement is executed repeatedly until condition becomes false.
Unlike for loop which iterates over a list, for using while loop you need to have an indicator variable i and change its value within each iteration. Otherwise you will have an infinite loop.