# In programming, loops are used to iterate over collections of data, such as lists or dictionaries.
# This allows us to perform operations on each item without manually writing repetitive code.
# In this example, we will iterate over a list of colors and a dictionary containing fruit details.
# Pseudocode:
# colors ← ["red", "blue", "green", "yellow"]
# FOR EACH color IN colors:
# DISPLAY color
# END FOR
# Example 1: Loop through a list of colors
colors = ["red", "blue", "green", "yellow"]
for color in colors:
print(color) # Display each color
# Example 2: Loop through a fruit dictionary
fruits = {"apple": 3, "banana": 5, "cherry": 7} # Number of each type of fruit
for fruit, quantity in fruits.items():
print(fruit, ":", quantity) # Display each fruit and its quantity
#Problem: Looping Through a List
#Create a list of your three favorite foods. Write a loop to display each food item in the list.
red
blue
green
yellow
apple : 3
banana : 5
cherry : 7