Python Loops
Author -
Programmer Fect
January 04, 2020
Python Loops
Loops are used to execute a block of statement for particular number of times.
A loop is a used for iterating over a set of statements repeatedly.
Types of Loops
1. for Loop
The for loop in Python is used to iterate over a sequence (list, tuple, string) and other iterable objects.
When you know the exact number of iterations.
Syntax :-
for var in sequence:
body
2. while Loop
The while loop in Python is used to iterate over a block of code as long as the test condition is true.
When you do not know the number of iterations.
Syntax :-
while boolean:
body