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: 
The way `urljoin` works is by combining a base URL and another URL. You could try joining the relative paths together with simple string combinations, and then use `urljoin` to join the host and the combined relative path.

Like:

```
rel = ver + exten
url = urljoin(host, rel)

```

Sadly if you want to combine multiple URL paths, you will have to use another library. If you're using a non-Windows machine, you could use the os.path module to join them together just like you would combine a local file path.
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)

```