'Finding the length of an element in a tuple
I have the following code:
{% set values = [ ('bank_transfer1', ('credit_card_1', 'complete')),
('bank_transfer2', ('credit_card_2'))]-%}
I want to print the above values in the form of a tuple like below:
bank_transfer1 is ('credit_card_1', 'complete')
bank_transfer2 is ('credit_card_2')
My attempt:
{% for val1, val2 in values%}
{{ val1 }} is {{ val2}}
{% endfor %}
The output I'm getting is:
bank_transfer1 is ('credit_card_1', 'complete')
bank_transfer2 is credit_card_2
How can I get the output in ('') if there is only one element in a tuple
I tried to print the length of the tuple, but this is giving me the length of the val2 as
2
12
How can I get print the output in the form of ('')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
