I have my_dict with sets as values and I have x which is also a set.
I need to return list with set from my dict which contain all numbers in x. If set in my_dict does not contain all numbers in x I do not want to return it.
I want to use intersection (&) but it returns all the sets in my_dict.
my_dict = {1: {1,2,3,4,5},
2: {1,2,3,7,8},
3: {1,2,3,4}
}
x = {1,2,5}
new_list = []
for i in my_dict:
if my_dict[i] & x:
new_list.append(i)
print(new_list)
Output:
[1, 2, 3]
I need to receive [1] instead of [1, 2, 3]