Mulai sekarangMulai gratis

Listing buckets

Sam has successfully created the buckets for her pipeline. Often, data engineers build in checks into the pipeline to make sure their previous operation succeeded. Sam wants to build in a check to make sure her buckets actually got created.

She also wants to practice listing buckets. Listing buckets will let her perform operations on multiple buckets using a for loop.

She has already created the boto3 client for S3, and assigned it to the s3 variable.

Help Sam get a list of all the buckets in her S3 account and print their names!

Latihan ini merupakan bagian dari kursus

Introduction to AWS Boto in Python

Lihat Kursus

Instruksi latihan

  • Get the buckets from S3.
  • Iterate over the bucket key from response to access the list of buckets.
  • Print the name of each bucket.

Latihan interaktif langsung praktik

Cobalah latihan ini dengan melengkapi kode contoh ini.

# Get the list_buckets response
response = s3.____()

# Iterate over Buckets from .list_buckets() response
for bucket in response['____']:
  
  	# Print the Name for each bucket
    print(bucket['____'])
Edit dan Jalankan Kode