Steven
Steven

Reputation: 53

Python dictionary multiple values per key iterating with jinja2

I have a dictionary (created from a Pandas dataframe):

{'name': 'steve', 'info': [{'pipeline': 'product1, product2'}]}

and this is the jinja2 sintax in a .docx template:

{% for x in info %} 
•   {{x[‘pipeline’]}}
{%endfor%}

the output is:

• product1, product2

but I'd like to have:

• product1

• product2

I'm not able to iterate and separate the values of the "info" key.

Upvotes: 0

Views: 84

Answers (1)

rayad
rayad

Reputation: 125

Seeing as the value of pipeline is a string you need to add info.split(',') to get [product1, product] as a list that you can iterate over

Upvotes: 1

Related Questions