# Changing the item in list of dictionaries

**URL:** <https://forum.ansible.com/t/changing-the-item-in-list-of-dictionaries/35096>\
**Category:** Ansible Project\
**Created:** [May 2, 2021, 11:09pm UTC](https://forum.ansible.com/t/changing-the-item-in-list-of-dictionaries/35096 "2021-05-02T23:09:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitchettri](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/amitchettri/32/404_2.png) [@amitchettri](https://forum.ansible.com/u/amitchettri)\
**Post date:** [May 2, 2021, 11:09pm UTC](https://forum.ansible.com/t/changing-the-item-in-list-of-dictionaries/35096/1 "2021-05-02T23:09:32Z")

</div>

Hi All,

Is there a possibility that I can change the value of a item in list of dictionaries comparing against another list value?  
Say for example I have  
1 list as [‘abc’, ‘null’, ‘xyz’] name **my\_list**  
And a list of dictionaries like below.

Then looping around the my\_list is it possible I can replace value of encryption\_password as null like “encryption\_password”: null

**But key points** is only on the second dictionary of the 3 this replacement must happen, as the null appear in my\_list in second place. If null appears in the 1st place in the my\_list then it should replace encryption\_password to null in the 1st dictionaries and respectively when null is 3rd place and replace should happen in 3rd dictionary.

msg: [  
{  
“auth\_method”: “md5”,  
“auth\_password”: “bdbhfdhq62637bdbd”,  
“encryption\_method”: “abc”,  
“encryption\_password”: “ndjsjs173jdjd”,  
“user”: “user1”  
},  
{  
“auth\_method”: “md5”,  
“auth\_password”: “bd345dhq6245677bdbd”,  
“encryption\_method”: “abc”,  
“encryption\_password”: “ndjjgskgdkdky3jdjd”,  
“user”: “user2”  
},

{  
“auth\_method”: “md5”,  
“auth\_password”: “357ghhrdgjfdhq62637bdbd”,  
“encryption\_method”: “abc”,  
“encryption\_password”: “hflhf35873789jd”,  
“user”: “user3”  
}

]

Regards  
Amit
