Markdown Card For Loop

No need for a loop to count lights that are on.
Take a look in this topic for multiple examples.

Lights that are on:

{{ states['light']  | selectattr('state','eq', 'on') | list | count }}