Help to create a "for next" loop for performing an action multiple times

Hi,

I’ve been searching for examples for a problem I have but couldn’t locate a solution so there for my post.
In an action part of an automation I would like to perform a loop of performing the same service a certain number of times.
In the code below I’d like to perform for example 3 screenshots.
Who can help?

- alias: 'Test Code'
  trigger:
    - platform: state
      entity_id: input_boolean.test_code
      from: 'off'
      to: 'on'
  action:
    - service: camera.snapshot
      data:
       entity_id: camera.tuin
       filename: '/config/snapshots/{{ now().strftime("%Y-%m-%d %H.%M.%S") }}_{{ entity_id.entity_id }}.jpg'
    - service: camera.snapshot
      data:
       entity_id: camera.tuin
       filename: '/config/snapshots/{{ entity_id.entity_id }}.jpg'
    - service: shell_command.send_image
      data:
        filename: '/config/snapshots/{{ entity_id.entity_id }}.jpg'
        token: !secret fb_page_access_token
        target:
          - xxxx'

I wrote AppDaemon to handle exactly this type of more complex automation.