# Looping thru a dictionary of dictionaries, then looping thru a list which is a value of a key in each item

**URL:** <https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929>\
**Category:** Ansible Project\
**Created:** [November 2, 2018, 4:41pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929 "2018-11-02T16:41:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [November 2, 2018, 4:41pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/1 "2018-11-02T16:41:28Z")

</div>

So I have a var, which is a dict of dicts, with one of the values (“patchset\_url\_list”) being a list (possibly empty):

`

TASK [print out ‘cuda\_versions’ var] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“cuda\_versions”: {  
“cuda\_10\_0”: {  
“cuda\_ver”: “10.0.130”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/10.0/Prod/local\_installers/cuda\_10.0.130\_410.48\_linux](https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux)”,  
“min\_driver\_ver”: 410.48,  
“patchset\_url\_list”: null  
},  
“cuda\_8\_0”: {  
“cuda\_ver”: “8.0.61”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/8.0/Prod2/local\_installers/cuda\_8.0.61\_375.26\_linux-run](https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run)”,  
“min\_driver\_ver”: 375.26,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda\_8.0.61.2\_linux-run](https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda_8.0.61.2_linux-run)”  
]  
},  
“cuda\_9\_0”: {  
“cuda\_ver”: “9.0.176”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/9.0/Prod/local\_installers/cuda\_9.0.176\_384.81\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run)”,  
“min\_driver\_ver”: 384.81,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda\_9.0.176.1\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.1_linux-run)”,  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda\_9.0.176.2\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda_9.0.176.2_linux-run)”,  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda\_9.0.176.3\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda_9.0.176.3_linux-run)”,  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda\_9.0.176.4\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda_9.0.176.4_linux-run)”  
]  
},  
“cuda\_9\_1”: {  
“cuda\_ver”: “9.1.85”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)”,  
“min\_driver\_ver”: 387.26,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)”,  
“[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)”,  
“[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)”  
]  
},  
“cuda\_9\_2”: {  
“cuda\_ver”: “9.2.148”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/9.2/Prod2/local\_installers/cuda\_9.2.148\_396.37\_linux](https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux)”,  
“min\_driver\_ver”: 396.37,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/9.2/Prod2/patches/1/cuda\_9.2.148.1\_linux](https://developer.nvidia.com/compute/cuda/9.2/Prod2/patches/1/cuda_9.2.148.1_linux)”  
]  
}  
}  
}

`

I can get the individual scalar values of a key in each item when I loop thru the dict, as so:

`

- name: Loop over versions, and show installer URL value for each item  
debug:  
msg: “Installer URL: {{ item.value.installer\_url }}”  
loop: “{{ cuda\_versions | dict2items }}”

(which gives me for example:)  
“msg”: “Installer URL: [https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)”

`

However, when I do that for the key “patchset\_url\_list” I of course get a list, as in this example:

`

“msg”: “Patch URL: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’]”

`

I cannot seem to figure out how to unroll the list, and take an action for each item in that list. I tried something like:

`

- name: Loop over versions, and show patch URL value for each item  
debug:  
var: item  
loop: “{{ cuda\_versions | dict2items | subelements(‘patchset\_url\_list’, skip\_missing=True) }}”

`

…but I’m getting no output. How can I do this?

---

<div class="post-metadata">

**Author:** ![ngonzal](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@ngonzal](https://forum.ansible.com/u/ngonzal)\
**Post date:** [November 2, 2018, 5:25pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/2 "2018-11-02T17:25:11Z")

</div>

I think you can just use subelement directly without dict2items:  
`  
loop: “{{ cuda\_versions | subelements(‘patchset\_url\_list’, ‘skip\_missing=True’) }}”

`

---

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [November 2, 2018, 5:59pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/3 "2018-11-02T17:59:26Z")

</div>

Unfortunately not, tried that and got:

`

TASK [Loop over versions, and show patch URL value for each item] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “the key ‘patchset\_url\_list’ should point to a list, got None”}

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 2, 2018, 6:01pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/4 "2018-11-02T18:01:55Z")

</div>

It do require a list, but you empty patchset\_url\_list is not empty it's a list.  
If you change it to a empty list instead of null it should work.

---

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [November 2, 2018, 6:44pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/5 "2018-11-02T18:44:58Z")

</div>

OK, my var now has a list value for every “patchset\_url\_list” value, as so:

`

TASK [print out ‘cuda\_versions’ var] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“cuda\_versions”: {  
“cuda\_10\_0”: {  
“cuda\_ver”: “10.0.130”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/10.0/Prod/local\_installers/cuda\_10.0.130\_410.48\_linux](https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux)”,  
“min\_driver\_ver”: 410.48,  
“patchset\_url\_list”: [  
null  
]  
},  
“cuda\_8\_0”: {  
“cuda\_ver”: “8.0.61”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/8.0/Prod2/local\_installers/cuda\_8.0.61\_375.26\_linux-run](https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run)”,  
“min\_driver\_ver”: 375.26,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda\_8.0.61.2\_linux-run](https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda_8.0.61.2_linux-run)”  
]  
},  
“cuda\_9\_0”: {  
“cuda\_ver”: “9.0.176”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/9.0/Prod/local\_installers/cuda\_9.0.176\_384.81\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run)”,  
“min\_driver\_ver”: 384.81,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda\_9.0.176.1\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.1_linux-run)”,  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda\_9.0.176.2\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda_9.0.176.2_linux-run)”,  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda\_9.0.176.3\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda_9.0.176.3_linux-run)”,  
“[https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda\_9.0.176.4\_linux-run](https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda_9.0.176.4_linux-run)”  
]  
},  
“cuda\_9\_1”: {  
“cuda\_ver”: “9.1.85”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)”,  
“min\_driver\_ver”: 387.26,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)”,  
“[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)”,  
“[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)”  
]  
},  
“cuda\_9\_2”: {  
“cuda\_ver”: “9.2.148”,  
“installer\_url”: “[https://developer.nvidia.com/compute/cuda/9.2/Prod2/local\_installers/cuda\_9.2.148\_396.37\_linux](https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux)”,  
“min\_driver\_ver”: 396.37,  
“patchset\_url\_list”: [  
“[https://developer.nvidia.com/compute/cuda/9.2/Prod2/patches/1/cuda\_9.2.148.1\_linux](https://developer.nvidia.com/compute/cuda/9.2/Prod2/patches/1/cuda_9.2.148.1_linux)”  
]  
}  
}  
}

`

And now the play doesn’t error (yay) but I’m still not getting a single string value as I expect… I have in my playbook now:

`

- name: Loop over versions, and show patch URL value for each item  
debug:  
msg: “Patch URL: {{ item }}”  
loop: “{{ cuda\_versions | subelements(‘patchset\_url\_list’) }}”

`

But I am getting the following output (example for one item):

`

ok: [localhost] =\> (item=[{u’cuda\_ver’: u’9.1.85’, u’min\_driver\_ver’: 387.26, u’patchset\_url\_list’: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’], u’installer\_url’: u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)’}, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’]) =\> {  
“msg”: “Patch URL: [{u’cuda\_ver’: u’9.1.85’, u’min\_driver\_ver’: 387.26, u’patchset\_url\_list’: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’], u’installer\_url’: u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)’}, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’]”  
}  
ok: [localhost] =\> (item=[{u’cuda\_ver’: u’9.1.85’, u’min\_driver\_ver’: 387.26, u’patchset\_url\_list’: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’], u’installer\_url’: u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)’}, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’]) =\> {  
“msg”: “Patch URL: [{u’cuda\_ver’: u’9.1.85’, u’min\_driver\_ver’: 387.26, u’patchset\_url\_list’: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’], u’installer\_url’: u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)’}, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’]”  
}  
ok: [localhost] =\> (item=[{u’cuda\_ver’: u’9.1.85’, u’min\_driver\_ver’: 387.26, u’patchset\_url\_list’: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’], u’installer\_url’: u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)’}, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’]) =\> {  
“msg”: “Patch URL: [{u’cuda\_ver’: u’9.1.85’, u’min\_driver\_ver’: 387.26, u’patchset\_url\_list’: [u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda\_9.1.85.1\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda\_9.1.85.2\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux)’, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’], u’installer\_url’: u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/local\_installers/cuda\_9.1.85\_387.26\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux)’}, u’[https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda\_9.1.85.3\_linux](https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux)’]”  
}

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 2, 2018, 7:02pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/6 "2018-11-02T19:02:36Z")

</div>

I really don't like the new loop syntax, the old one is better

&nbsp;&nbsp;- name: Loop over versions, and show patch URL value for each item  
&nbsp;&nbsp;&nbsp;&nbsp;debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "Patch URL: {{ item.1 }}"  
&nbsp;&nbsp;&nbsp;&nbsp;with\_subelements:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "{{ cuda\_versions }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- patchset\_url\_list

Then it's easy to remember that the fist one i item.0 (content of "{{ cuda\_versions }}") and item.1 (content of patchset\_url\_list)

---

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [November 2, 2018, 7:15pm UTC](https://forum.ansible.com/t/looping-thru-a-dictionary-of-dictionaries-then-looping-thru-a-list-which-is-a-value-of-a-key-in-each-item/28929/7 "2018-11-02T19:15:57Z")

</div>

Right, came to that same conclusion after staring at the data for a bit … Thanks for the assist! 🙂
