There is basically two types of loop used in python.
For loop
While loop
For loop
For loop is mostly used to iterate list, dictionary, tuple & strings. For loop iterate over list elements until it reach to end of list.
Syntax of for loop
for index in sequence:
Block code
Example:
department = ['Math', 'Science', 'Physics']
for dep in department:
print(dep, len(dep))
Output
('Math', 4)
('Science', 7)
('Physics', 7)
While Loop
While loop is used to execute block of code until while loop condition is TRUE.
Syntax:
While condition:
Statements
Example:
count = 1
while (count < 6):
count = count + 1
print("Hello")
Output
Hello
Hello
Hello
Hello
Hello
For more detailed with multiple scenarios and questions please check Different types of loops in python .