What is While loop in Python?
- A While loop in Python is used to execute a set of statements/ iterate over a block of code repeatedly as long as the given condition is true.
- While loop is preferred when we don't know the number of iterations.
Syntax:
while condition:
body statements
- The body statement of the while loop is separated from the rest of the code using indentation [tab].