You could retrieve both key and value using the dictionary's **items()** method. If there are no values for the given key, you don't add it to **tail**:

```python
for key, val in options.items():
    if val:
        tail += " --%s='%s'" % (key, value)
    else:
        tail += " --%s" % key
```