How can I extract hello from the code using indexing?
I_say = {'stairs_1':[1, 'two', {'stairs_2':['Close to the door', {'in the door':['one', 2, ['hello']]}]}]}
I completely understand why this question was downvoted. It's just basic knowledge that a Python tutorial would help you with.
Nevertheless, it would help you immensely if you'd reformat your code and make it more readable.
{
"stairs_1":[
1,
"two",
{
"stairs_2":[
"Close to the door",
{
"in the door":[
"one",
2,
[
"hello"
]
]
}
]
}
]
}
After looking at this code, you can see that the first level is a dictionary with a key stairs_1
, its value is a list of three values.
The third value is a dictionary that contains just one element. Again, stairs_2
is the key and the value is a list, this time of two elements.
The second element is a dictionary that contains one element, its key is in the door
and the value is a list.
The list contains three elements, while the third one is a list with a single element - your "hello"
string.
So the answer is I_say['stairs_1'][2]['stairs_2'][1]['in the door'][2][0]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments