---
id: 67ee56687454b01015480e90
title: Task 8
challengeType: 22
dashedName: task-8
lang: en-US
---

<!-- (audio) Sophie: You used a simple for loop, but given our use case, you should have used a while loop instead. -->

# --instructions--

Listen to the audio and complete the sentence below.

# --fillInTheBlank--

## --sentence--

`You used a simple BLANK, but given our use case, you should have used a BLANK instead.`

## --blanks--

`for loop`

### --feedback--

This two-word phrase refers to the loop that is used when you know how many times it should run.

---

`while loop`

### --feedback--

This two-word phrase refers to the loop that is used when the number of repetitions depends on a condition.

# --explanation--

A `for loop` is useful when you know how many times the loop should run. For example:

- `A for loop is useful for going through a list.` - You can use it to check each item in a list.

- `The for loop stops when it reaches the last item.` - The loop ends when there are no more items.

A `while loop` is better when the number of repetitions depends on a condition. For example:

- `A while loop runs until a condition is false.` - The loop continues as long as the rule is true.

- `Be careful, a while loop can run forever!` - If you don't stop it, the loop won't end.

# --scene--

```json
{
  "setup": {
    "background": "company2-center.png",
    "characters": [
      {
        "character": "Sophie",
        "position": {
          "x": 50,
          "y": 0,
          "z": 1.4
        },
        "opacity": 0
      }
    ],
    "audio": {
      "filename": "B1_17-1.mp3",
      "startTime": 1,
      "startTimestamp": 12.0,
      "finishTimestamp": 16.36
    }
  },
  "commands": [
    {
      "character": "Sophie",
      "opacity": 1,
      "startTime": 0
    },
    {
      "character": "Sophie",
      "startTime": 1,
      "finishTime": 5.26,
      "dialogue": {
        "text": "You used a simple for loop, but given our use case, you should have used a while loop instead.",
        "align": "center"
      }
    },
    {
      "character": "Sophie",
      "opacity": 0,
      "startTime": 5.76
    }
  ]
}
```
