# Format two List Comparison

**URL:** <https://forum.ansible.com/t/format-two-list-comparison/32159>\
**Category:** Ansible Project\
**Created:** [February 6, 2020, 4:00pm UTC](https://forum.ansible.com/t/format-two-list-comparison/32159 "2020-02-06T16:00:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [February 6, 2020, 4:00pm UTC](https://forum.ansible.com/t/format-two-list-comparison/32159/1 "2020-02-06T16:00:35Z")

</div>

Hi ,

Someone barged into my ongoing Discussion . So i had to start a new Discussion.

If my items of lists are not fixed on both the list , how do i compare them:

Now i have one more issue on the LIST comparison:  
If the numbers of items in list is not equal is there way to compare:

suppose my lists are:  
list1  
“dp-steps-common-3.0.12”,  
“iam-python-common-1.0.1”,  
“iam-service-default-3.1.37”  
list2:  
“dp-steps-common-3.0.15-1911280809\_d103a.noarch”,  
“iam-service-default-3.1.37-1911141021\_63e48.noarch”

- name: If the List comparision is not equal  
debug:  
msg: “{{ item.0 }} is not equal to {{ item.1 }}”  
loop: “{{ list1|sort|zip(list2|sort)|list }}”  
when: item.0.split(‘-’)[-1] is not version(item.1.split(‘-’)[-2])

If i execute the playbook,all elements on list1 are compared with all elements on list2.

I want my o/p should be as follows:  
dp-steps-common-3.0.12 not equal to dp-steps-common-3.0.15-1911280809\_d103a.noarch

iam-service-default-3.1.37 equal to iam-service-default-3.1.37-1911141021\_63e48.noarch

iam-python-common-1.0.1 is not present on List2
