diff --git a/kaggle/api/kaggle_api_extended.py b/kaggle/api/kaggle_api_extended.py
index <HASH>..<HASH> 100644
--- a/kaggle/api/kaggle_api_extended.py
+++ b/kaggle/api/kaggle_api_extended.py
@@ -2018,6 +2018,7 @@ class KaggleApi(KaggleApi):
             outfiles.append(outfile)
             download_response = requests.get(item['url'])
             if force or self.download_needed(item, outfile, quiet):
+                os.makedirs(os.path.split(outfile)[0], exist_ok=True)
                 with open(outfile, 'wb') as out:
                     out.write(download_response.content)
                 if not quiet:
Update kaggle_api_extended.py

Solves issue #<I>: kernels output fails if the kernel is creating output subfolders