Hi I would like to compare two list that are different lengths and print a sorted table with items that are missing in each table. I am partially able to accomplish this and print the values that are missing in list_2. But I am unable to also print the values that are missing in list_1 from list_2, the letter 'z'. How can I perform this to get the desired output below?
list_1 = ['a', 'b', 'c', 'd', 'e', 'f']
list_2 = ['b', 'c', 'f', 'z']
table_format = '{:<10} {:<10}'
print(table_format.format('list_1', 'list_2'))
print('-' * 20)
for x in list_1:
for y in list_2:
if x in y:
print(table_format.format(x, y))
break
else:
print(table_format.format(x,'Missing'))
Current Output:
list_1 list_2
--------------------
a Missing
b b
c c
d Missing
e Missing
f f
Desired Output:
list_1 list_2
--------------------
a Missing
b b
c c
d Missing
e Missing
f f
Missing z