Loops and Iteration
For Loops and While Loops 1. For Loops Purpose: Used to iterate over a sequence (like a list, string, tuple, range, etc.) Syntax: for variable in iterable: # code block Example 1: Looping through a list fruits = [“apple”, “banana”, “cherry”] for fruit in fruits: print(fruit) Output: apple banana cherry Example 2: Using range() for … Read more