Question: I got a query result in array `Array ( [0] => stdClass Object ( [model] => Peugeot 308 SW ) [1] => stdClass Object ( [model] => Citroen C-Elysee ) [2] => stdClass Object ( [model] => Nissan Evalia ) [3] => stdClass Object ( [model] => Renault Trafic 9-os ) )`

And I want to make a single variable for every object like:

$Peugeot 308 SW  

$Citroen C-Elysee  

$Nissan Evalia

But I don't know how to do that. Thank you

Answer: 
Use [`dict.setdefault()`](https://docs.python.org/3/library/stdtypes.html#dict.setdefault):

```
>>> d = {'key1': 'one'}
>>> d.setdefault('key1', 'some-unused-value')
'one'
>>> d    # d has not changed because the key already existed
{'key1': 'one'}
>>> d.setdefault('key2', 'two')
'two'
>>> d
{'key1': 'one', 'key2': 'two'}

```
Since **Python 3.9** you can use the *merge operator* `|` to merge two dictionaries. The dict on the right takes precedence:

```py
new_dict = old_dict | { key: val }

```

For example:

```py
new_dict = { 'a': 1, 'b': 2 } | { 'b': 42 }

print(new_dict) # {'a': 1, 'b': 42}

```

Note: this creates a new dictionary with the updated values.