0

I am trying to get the value of DomainName from the below dictionary.

print(domain_name)

# output
{
    'DomainNames': [
        {
            'DomainName': 'some-value'
        },
    ]
}

I have tried:

print(domain_name['DomainNames'][0]['DomainName'])

but it doesn't give that value. I even tried:

print(domain_name['DomainNames']['DomainName'])

Here is my code:

def add_es_tags():

    for region in get_regions_depending_on_account():
        pass
    es_client = boto3.client('es', region_name="us-east-1")
    response = es_client.list_domain_names()

    get_es_domain_ARN("us-east-1", response)


def get_es_domain_ARN(region, domain_names):
    es_client = boto3.client('es', region_name=region)

    arns = [] 
    print(len(domain_names))
    for domain_name in domain_names:
        # print(type(domain_name))
        print(domain_name['DomainNames'][0]['DomainName'])
Jananath Banuka
  • 2,951
  • 8
  • 57
  • 105

1 Answers1

0

Like this:

domain_name = {
    'DomainNames': [
        {
            'DomainName': 'some-value'
        },
    ]
}

print(domain_name)

print(domain_name['DomainNames'][0]['DomainName'])

Yes, the answer is: it works exactly as you suggested!

Edit: Never mind, I'll update this when you've formulated a full question that actually matches what you're doing.

poleguy
  • 523
  • 7
  • 11