Question: ```
names = {'bob':3, 'jack':1,'suzy':0,'amy':5}

def only_child(d:dict)->dict:
'''if the value(# of siblings) for the key(the person) == 0, change the value to True, 
otherwise leave the dictionary entry as is.'''

    return {name:True for name in d if d[name] == 0}

```

this only gives me `{'suzy': True}`

I tried this:

```
return {name:True for name in d if d[name] == 0 else name:d[name]}

```

but I get a `SyntaxError`.

is there a way that i could write this function in a single line of code(like i've been trying to do)? i like to keep them as short and concise as possible.
the solution should look like

```
names = {'bob':3, 'jack':1,'suzy':True,'amy':5} 

```

any help would be appreciated.

Answer: 
You are filtering out the non-zero items, see the below:

```
def only_child(d:dict)->dict:
    return {name: True if num == 0 else num for name, num in d.items() }

```

and [this construct](https://docs.python.org/3/reference/expressions.html#conditional-expressions) is called a `conditional expression`, or the `ternary operator`.

You can achieve the same result without creating a new dictionary, in-place:

```
def only_child(d:dict)->dict:
    for name, num in d.items():
        if num == 0: d[name] = True
    return d

```
**TL;DR: You should have the conditional as part of the value expression, not the dict comprehension**

If you put the test in the condition, then the result of the comprehension will be restricted. If you want to change the value the test should be in the value expression instead. You can use a ternary for that.

```
{k:True if names[k]==0 else names[k] for k in names}

```