https://api.x.com//v1/users or miss slashes. Write api_url(base, *segments) joining a base URL and path segments with exactly one / between parts, regardless of stray slashes on the inputs.api_url('https://api.x.com/', '/v1/', 'users', 42)'https://api.x.com/v1/users/42'
Extra slashes were normalized away.
base.rstrip('/') plus each segment str(s).strip('/').
'/'.join finishes it.