Complex repeat

Hello,
I have to create a script with a repeat.
In the repeat 4 things are done.
However, one of these is longer than the others and slows down the “sequential” times of the script.
I thought I’d do something equivalent to this

repeat: 20
    Action1
    Action2
    Action3
    if repeatCount%2=0 then do Action4

i.e. perform Action4 once yes and once no (module 2 but I could think of using module 3 or 4 depending on the purpose)
Is there a similar function on HA? Or how can I simulate it?
my current script is

- repeat:
      count: '20'
      sequence:
      - data: {}
        entity_id: switch.sonoff_XXXXXXXXXX
        service: switch.toggle
      - entity_id: switch.sonoff_YYYYYYYYY
        service: switch.toggle
      - device_id: XYZXYZXYZ
        domain: switch
        entity_id: switch.test_mss210r_main_channel
        type: toggle
      - service: notify.alexa_media_echo_dot
        data:
          message: MESSAGE TO SPEAK
          title: Title of message
          data:
            type: announce
            method: spoken
          target: media_player.alexa

Can anyone help me to add condition to action 4, or use more complex counter, or… thell me best way!
Thanx

Could have done it with the choose option but templates are neater:

- repeat:
      count: '20'
      sequence:
      - data: {}
        entity_id: switch.sonoff_XXXXXXXXXX
        service: switch.toggle
      - entity_id: switch.sonoff_YYYYYYYYY
        service: switch.toggle
      - device_id: XYZXYZXYZ
        domain: switch
        entity_id: switch.test_mss210r_main_channel
        type: toggle
      - condition: template
        value_template: "{{ count|int % 2 == 0 }}"
      - service: notify.alexa_media_echo_dot
        data:
          message: MESSAGE TO SPEAK
          title: Title of message
          data:
            type: announce
            method: spoken
          target: media_player.alexa

That’s exactly what I meant.
However it doesn’t work: to simplify I reduced 6 reps and 2 actions.
The first call is done 6 times, the second, after the condition, never.

the variable is repeat.index

- repeat:
      count: '20'
      sequence:
      - data: {}
        entity_id: switch.sonoff_XXXXXXXXXX
        service: switch.toggle
      - entity_id: switch.sonoff_YYYYYYYYY
        service: switch.toggle
      - device_id: XYZXYZXYZ
        domain: switch
        entity_id: switch.test_mss210r_main_channel
        type: toggle
      - condition: template
        value_template: "{{ repeat.index % 2 == 0 }}"
      - service: notify.alexa_media_echo_dot
        data:
          message: MESSAGE TO SPEAK
          title: Title of message
          data:
            type: announce
            method: spoken
          target: media_player.alexa

still not work…

Could this be an indentation error?
alexa