code: def create_dirs(path):
      
      fname = os.path.basename(path)
  
      # if file name exists in path, skip the filename
      if fname.__contains__('.'):
          path = os.path.dirname(path)
  
      if not os.path.exists(path):
          os.makedirs(path)
docs: Creates all directories mentioned in the given path.
          Useful to write a new file with the specified path.
          It carefully skips the file-name in the given path.
  
      :param path: Path of a file or directory