# Example of Using a For Each Activity

> To exemplify how to use a **For Each** activity, let’s create an automation that goes through each element of an array of integers and writes the length of the array and each element to the **Output** panel.

To exemplify how to use a **For Each** activity, let’s create an automation that goes through each element of an array of integers and writes the length of the array and each element to the **Output** panel.

1. Create a new sequence.
2. Create an array of integer variables, `FibonacciNumbers`.
3. In the **Default** field, type the Fibonacci sequence up to a desired value, such as {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89}.
4. Add a **For Each** activity in the **Designer** panel.
5. Do not make any changes to the **ForEach** field.
6. In the **In** field, add the `FibonacciNumbers` variable. This activity looks at each individual item in the provided variable.
7. In the **Body** section of the **For Each** activity, add a [Write Line](https://docs.uipath.com/activities/docs/write-line) activity.

8. On the right side of the **Text** field, select **Plus** ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-plus_menu-8a20ac7d.png) &gt; **Open in Advanced Editor**.

9. Inside the **Expression Editor** window, type "The length of this Fibonacci sequence is " + `FibonacciNumbers.Length.ToString` + " and contains the " + `item.ToString` + " element.". This expression enables you to write the total number of array elements and each element of the array in the **Output** panel.

The final project should look as in the following screenshot.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-167402-ba174a96.webp)

10. Press F5. The automation is executed. Note that the **Output** panel displays the correct message for each element of the array.
    :::note
    The **Length** property enables you to find out the total number of array elements.
    :::

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-166852-d29853f4.webp)

[Download example](https://documentationexamplerepo.blob.core.windows.net/examples/Studio_v2022.10/ForEachActivity_2.zip)
