For Loop Limit

Hey,

I created this markdown to show me sorted fuel prices. However, I would like to display a maximum of 5. How can I minimize this For loop to 5 outputs ?

Markdown:

type: markdown
content: >-
  # E10: {% for  entity in  expand('group.tanken_benzin') |
  sort(attribute='state') | map(attribute='entity_id') | map('string')  | list
  %} 
    {{state_attr(entity, "friendly_name")}}
    ## {{states(entity) }} €
    ***
  {% endfor%}

One option is to use list slicing:

type: markdown
content: >-
  # E10: {% for  entity in  (expand('group.tanken_benzin') |
  sort(attribute='state') | map(attribute='entity_id') | list))[:5]
  %} 
    {{state_attr(entity, "friendly_name")}}
    ## {{states(entity) }} €
    ***
  {% endfor%}