L1/10

Repeating With a for Loop

A loop lets you repeat a block of code without copying it.

python
tools = ["rope", "map", "torch"]
for tool in tools:
    print(tool)

Here is what the example does:

  • tools creates a list and stores it in tools.
  • The for loop takes each item from tools one at a time and puts it into tool.
  • print(tool) displays the value stored in tool.

The assignment uses different values, but you will use the same loop pattern.

Assignment

Complete the starter code so the program does the following:

  • Use a for loop to go through each number in [1, 2, 3].
  • Inside the loop, print number.

Your finished program should print exactly this output:

text
1
2
3

Be very careful with capitalization, spaces, and line breaks. The output must match exactly.