Lax Mandis
Lax Mandis

Reputation: 131

Extracting Dictionary Value from a Tuple

I have a tuple which is basically like this:

t=(OrderedDict([('attributes', OrderedDict([('type', 'User'), ('url', '/services/data/v38.0/sobjects/User/0006Cx6pIAC')])), ('Name', 'Ben Dams')]),)

How do I extract just the 'Name' from the dictionary?

Upvotes: 0

Views: 41

Answers (1)

jpp
jpp

Reputation: 164663

You have a single-value tuple which contains a dictionary. So just use indexing before accessing a dictionary key:

res = t[0]['Name']  # 'Ben Dams'

Upvotes: 2

Related Questions