[Python 3.4] Extract key and value from multiple dictionaries within a single list

Hello all, I have a json file which I have reached a list with multiple dictionaries.

[{'code': '32',
  'date': '25 Jul 2016',
  'day': 'Mon',
  'high': '98',
  'low': '56',
  'text': 'Sunny'},
 {'code': '32',
  'date': '02 Aug 2016',
  'day': 'Tue',
  'high': '94',
  'low': '58',
  'text': 'Sunny'},
 {'code': '32',
  'date': '03 Aug 2016',
  'day': 'Wed',
  'high': '98',
  'low': '58',
  'text': 'Sunny'}] 

I wish to write a loop that will get me an output like so:

code: 32
date: 25 Jul 2016
day: Mon

etc.

for item in d:
    for key in item:
        print(key)

The loop above gets me the keys, but I can't get to the values. IF someone could assist I'd appreciate it.

Thanks.

Posted Jul 25, 2016, 4:51 PM UTC

27
Loading comments…