Preview:
def get_folder_in_s3_bucket(bucket, prefix):
    try:
        s3_bucket_data = client.list_objects(Bucket= bucket, Prefix= prefix, Delimiter="/")
        s3_folder_list =  [(prefix_dict['Prefix']).removeprefix(prefix) for prefix_dict in s3_bucket_data.get("CommonPrefixes", None)]
        return s3_folder_list
    except Exception as e:
        print(f"There is an error as {e}")
        return None
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter