Question: I am having a simple doubt..
 I am trying to join three parts of a string using urljoin..

```
   host = "http://foo.com:port"
   ver = "/v1"
   exten = "/path"

```

Rather than doing host+ver+exten, I want to use urljoin to generate url
 But urljoin is giving 
 `http://foo.com:poort/v1` ( if i try `urljoin(host,ver,exten)` )

Answer: 
You can also join your list of parts recursively:

```
def urljoin(parts):
    if len(parts) > 1:
        parts = [urllib.parse.urljoin(parts[0], parts[1])] + parts[2:]
        return urljoin(parts)

    return parts[0]

```

Use the function like this:

```
parts = [
    'https://stackoverflow.com/',
    'questions/24814657/',
    'how-to-do-url-join-in-python-using-multiple-parameters/',
    '41756140#41756140',
]

print(urljoin(parts))
# https://stackoverflow.com/questions/24814657/how-to-do-url-join-in-python-using-multiple-parameters/41756140#41756140

```

Note that `urllib.parse.urljoin()` has a bit different behavior than `os.path.join()` mentioned by @AnukuL.
You could use the [str.**join**](https://docs.python.org/3/library/stdtypes.html#str.join) function, as suggested in this other [answer](https://stackoverflow.com/a/36189633):

```
url = urljoin('http://example.com:port', '/'.join(['v1','path']))

```

If the path segments contains one or more slash `/`, use [str.**strip**](https://docs.python.org/3/library/stdtypes.html#str.strip) first:

```
path='/'.join(map(lambda s: s.strip('/'), ["/v1", "/path"]))
url = urljoin('http://example.com:port', path)

```