Loop range format quick question

HI,

quick question about how to use a variable in loop range:

I got this:

loop: “{{range (0, 2+1) | list}}”

and this is what i want to use:

loop: “{{range (0, myvariable +1) | list}}”

where “myvaribale” contains number 2

but it comes back with an error when i run it, i also tried to put myvariable in double quote, single quote, but no help, is there any specific format to put myvariable in here?

Thanks,
Dave.

HI,

quick question about how to use a variable in loop range:

I got this:

loop: "{{range (0, 2+1) | list}}"

and this is what i want to use:

loop: "{{range (0, myvariable +1) | list}}"

where "myvaribale" contains number 2

but it comes back with an error when i run it, i also tried to put myvariable in double quote, single quote, but no
help, is there any specific format to put myvariable in here?

You might need to use myvariable | int as Jinja results are strings - but it is always helpful to post the error with
your question.

Regards
          Racke

Thanks Stefan, used the following and it’s working like you said:

loop: “{{range (0, myvariable | int +1) | list}}”