How to get rid of "new lines" from a for loop?

Hi!

I have this card

{% set rates =  states.sensor.rooms_occupancy.attributes | list %}
{% set rates2 =  states.sensor.rooms_occupancy.attributes.values() | list %}
{% for i in range(0, rates | count, 1) %}
  {% if rates2[i] == "off" %}
  {{ rates[i] }}
  {% endif %}
{% endfor %}

and the result is this:

Anyone knows how to get rid of those spaces between rows?

Thank you in advance!

Nevermind, seems that there is a margin css involved :smiley:

I don’t remember the exact answer, but you can do something like β€œ-}” instead of β€œ%}” to avoid adding a new line in your template.
-David

1 Like

As @dbs says you can use β€œ-”:

https://jinja.palletsprojects.com/en/3.1.x/templates/#whitespace-control