How to get from two lists only the number from second that do not exist in first list in Python

1 Answer

0 votes
list_a = [1, 2, 2, 3, 3, 4, 5]
list_b = [2, 3, 4, 8, 9]

first_list_set = set(list_a)
second_list_set = set(list_b)

numbers_only_in_second_list = second_list_set - first_list_set

print(numbers_only_in_second_list)


'''
run:

{8, 9}

'''

 



answered Nov 15, 2017 by avibootz
...