Module 13: Practice Zone

Mastering loops: `for` iterating over data!

Anatomy of a `for` Loop

Loops let us repeat actions. Click each highlighted part of this `for` loop to understand its role in iterating over a list.

for item in my_list:
print(item) # Action for each item

Identify all 6 parts!

Build-a-Loop

Drag the pieces into the dark area to build a `for` loop that prints each character of the string "AI". Remember the colon and indentation!

Drop pieces here (line 1: header, line 2: body)...

Loop Simulator

Write a `for` loop in the editor. Try iterating over the pre-defined `data` (list or string selected below) and printing each element.

Output will appear here...

Choose the Right Loop

Which code snippet correctly solves the problem described? Click your choice, then check your answer.

Problem: Print each letter from the word "DATA" on a new line.

Loop Challenges

Apply your loop knowledge! Complete these small coding challenges using the editor provided in each.

Challenge 1: List Iteration

Given the list `topics = ["AI", "ML", "Data"]`, write a loop to print each topic on a new line.

Challenge 2: String Iteration

Given the string `word = "PYTHON"`, write a loop to print each character separated by a hyphen (e.g., P-Y-T-H-O-N-). Hint: Use `print(char, end="-")`.

Challenge 3: Processing in a Loop

Given `numbers = [5, 10, 15]`, write a loop that prints each number increased by 1 (i.e., 6, 11, 16).

Module 13 Practice Complete!

Excellent looping! You've practiced iterating over lists and strings.
Ready for more complex loops? Try the Advanced Practice for Module 13!