Move the if
at the end:
b = dict( (key, value) for (key, value) in a.items() if key == "hello" )
You can even use dict-comprehension (dict(...)
is not one, you are just using the dict
factory over a generator expression):
b = { key: value for key, value in a.items() if key == "hello" }