Accessing A Dictionary Item That is an Array

I have the following dictionary defined:

‘items’:[‘Temp Control’,‘Blowers’,‘System Info’,‘Network’]

I cannot figure out the correct syntax for accessing the nth element of ‘items’.


Gw1500se1 defined a dict:

      'items':['Temp Control','Blowers','System Info','Network']

then tried this:


Break it down step-by step:

  • menu['main'] returns the string ‘Main’;

  • 'items'[0] returns the character 'i';

  • so the third step becomes 'Main'['i'] which fails.

Instead, you need:

  • menu['items'] to return the list;

  • followed by indexing the n-th element of the list.

Putting them together with the call to print gives us:


which prints “Temp Control”.

1 Like

Thanks for the reply. I see now. I was thinking one level too deep. I was treating items as if it were an element of main rather than menu.