I meet some problem while I try to use the element of list as the key of dict in Django.
My code is below:
list = ['a', 'b', 'c']
dict = {'a' : 1, 'b' : 2, 'c' : 3}
{% for element in list %}
{% for key, value in dict %}
{{ value.element }}
{% endfor %}
{% endfor %}
The question is that there is no key named element
in dict, so it won't show the correct value.
The correct result should be 1
, 2
, 3
.
How can I use element of list as the key of dict instead of using the specific key in Django.
Thank you.