I’m encountering a loop issue that I’m unsure how to solve cleanly. Suppose I have a list of dictionaries:
list_of_dict:
{ key: d01, value: ‘v1’ }
{ key: d02, value: ‘v2’ }
…
{ key: d99, value: ‘v99’ }
Somewhere else I have another list whose elements are a subset of the keys in list_of_dict:
list01:
d01
d07
d33
There are many other lists like list01 with a similar structure. How do I loop through list01 while echoing the corresponding ‘value’ from list_of_dict?
the above code got this error message, how to fix it ?
TASK: [debug msg=“{{ list_of_dict[item] }}”] **********************************
fatal: [localhost] => One or more undefined variables: ‘list object’ has no attribute ‘d01’
My understanding is that list_of_dict, being a list, should be indexed by integer and not by a string such as ‘d01’. Try the code in Chip’s response; it runs successfully.