Description: Looping in Python refers to the process of executing a block of code repeatedly based on a condition.Python has two loops 'for' and 'while'
Step-by-Step Process
for loop: The for loop iterates over each item in a sequence until all items have been processed.
while loop: The while loop repeatedly executes a block of code as long as a given condition remains true.
Sample Code
#for loop:
fruits = ["apple", "banana", "cherry"]
print("Output of for loop:")
for i in fruits:
print(i)
print()
#While loop:
count = 0
print("Output of while loop:")
while count < 7:
print("Count is:", count)
count += 1