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

```
If I understand what you are asking:

```
>>> names = {'bob':3, 'jack':1,'suzy':0,'amy':5}
>>> {k:(v==0 or v) for k,v in names.items()}
{'amy': 5, 'bob': 3, 'jack': 1, 'suzy': True}

```