Mairaj Khan
Mairaj Khan

Reputation: 359

getting value by tuple of dictionary of dictionary

I have a tuple of dictionary of dictionary of list, I want to print value like

1
2
3

the given tuple is, how can I print that value. k=('m',{'n':{'o':[1,2,3]}})

Upvotes: 0

Views: 93

Answers (2)

user2314737
user2314737

Reputation: 29317

Also:

 for i in  k[1]['n']['o']:
   print i

Upvotes: 3

thefourtheye
thefourtheye

Reputation: 239473

You can access the innermost list, like this k[1]["n"]["o"] and then we convert each element of it to a string, which we later join with \n and print it.

print "\n".join(map(str, k[1]["n"]["o"]))

Output

1
2
3

Upvotes: 3

Related Questions