### Week 10: Control flow with for loop and while loop in Python. > By *Akinlade Temitope* Moving on from control flow with conditionals, we were introduced to the concept of looping which was explained as a way of executing repetitive task efficiently. #### FOR LOOP This loop allows one to iterate through and perform a task on each item in a list of items than can be in an iterable data type on in a defined range Example: ```python! for i in range(1,5): print(i) # Output: 1,2,3,4 names = ["Temi","Dan","Phil"] for name in names: print(name) # Output: Temi,Dan,Phil ``` #### WHILE LOOP This loop executes only when a certain condition is True and terminates when the condition evaluates to False or with the break keyword or using the continue keyword to continue the loop even if a certain condition is met Example: ```python! i = 0 while i <= 5: print(i) i += 1 # Output: 0,1,2,3,4,5 while i <= 5: if i == 2: print(i) break i += 1 # Output: 2. while i <= 5: if i == 2: continue else: print(i) i += 1 # Output: 0,1,3,4,5 ``` #### NOTE The break and continue keyword are applicable in both for loop and while loop ### CONCLUSION It was an exciting week being introduced to how to simplify repetitive task and i look forward to doing more with loops. Thanks for sticking around. See you soon.