# How to compare matches from 2 different lists and output them in this specific way, python

I have 2 different lists which I need to compare and output them in this specific way

Sample Tests
Input

``````1 2 3 4 5 7
1 2 4 4 5 6
``````

Output

``````+ 1 1
+ 2 2
- 3 4
+ 4 4
+ 5 5
- 7 6
``````

Any guidance on how I can do this please?

``````numbers1_input=input().split()
numbers2_input=input().split()

numbers_1=[]
for x in numbers1_input:
numbers_1.append(int(x))

numbers_2=[]
for y in numbers2_input:
numbers_2.append(int(y))
``````

So far I have created the input into 2 lists

### >Solution :

``````numbers1_input="1 2 3 4 5 7".split()
numbers2_input="1 2 4 4 5 6".split()

numbers_1=[]
for x in numbers1_input:
numbers_1.append(int(x))

numbers_2=[]
for y in numbers2_input:
numbers_2.append(int(y))

for n1, n2 in zip(numbers_1, numbers_2):
print(f"{'+' if n1==n2 else '-'} {n1} {n2}")
``````

EDIT:
If one of the lists can be longer, you can use `itertools.zip_longest` to fill shorter iterables with whatever you need:

``````from itertools import zip_longest

for n1, n2 in zip_longest(numbers_1, numbers_2, fillvalue="x"):
print(f"{'+' if n1==n2 else '-'} {n1} {n2}")
``````