Question: I have this list:

```
list1 = [{'Hello'}, {'Welcome'}, {'BYE'}]

```

And I have a dictionary:

```
dict1 = {'Welcome': 5, 'BYE': 3, 'How are you': 3}

```

I would like the result to be something like:

```
dict2 = {'Welcome': 5, 'BYE': 3}

```

According to this [post](https://stackoverflow.com/questions/11157704/python-intersection-between-a-list-and-keys-of-a-dictionary).
I tried:

```
dict2 = {k: dict1[k] for k in (dict1.keys() & list1)}

```

But it says:

> 
> TypeError: unhashable type: 'set'
> 
> 
> 

Do I need first to make list1, like this:

```
list1 = ['Hello', 'Welcome', 'BYE']

```

And if this is the problem, then how?

Answer: 
You can make a set of value from the `list1`:

```py
list1 = [{"Hello"}, {"Welcome"}, {"BYE"}]
dict1 = {"Welcome": 5, "BYE": 3, "How are you": 3}

dict2 = {k: dict1[k] for k in (dict1.keys() & {v for s in list1 for v in s})}
print(dict2)

```

Prints:

```py
{'BYE': 3, 'Welcome': 5}

```
Yes your variable list1 is a list of set, you might do this:

```
dict2 = {k: dict1[k] for k in set(dict1.keys()).intersection(set().union(*list1))}

```