You can use a for loop to loop around the buckets in your S3. In boto3 there is a fucntion that helps this task go easier.(buckets.all())
You can use the following program to print the names of bucket
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
Hope this helps!!
If you need to learn more about Python, It's recommended to join Python Training today.