def set(self, name, value=None):
        "Return a new DecodedURL with query parameter *name* set to *value*"
        query = self.query
        q = [(k, v) for (k, v) in query if k != name]
        idx = next((i for (i, (k, v)) in enumerate(query) if k == name), -1)
        q[idx:idx] = [(name, value)]
        return self.replace(query=q)
Return a new DecodedURL with query parameter *name* set to *value*
stackoverflow/venv/lib/python3.6/site-packages/hyperlink/_url.py