Getting items from multiple dictionaries inside tuple

  dictionary, python, tuples

I have the following piece of code based on PythonMETAR (some sort weather codification in aviation) library:

from PythonMETAR import *
report = Metar('LRSM')
properties = report.getAttribute('cloud')
print(report)

print(properties)

which returns me the following result:

LRSM 071100Z 28005KT 220V320 9000 -RA FEW006 BKN025 BKN035 12/11 Q1010 R01/29//95

({'code': 'FEW', 'meaning': 'Few', 'oktaMin': 1, 'oktaMax': 2, 'altitude': 600, 'presenceCB': False, 'presenceTCU': False}, {'code': 'BKN', 'meaning': 'Broken', 'oktaMin': 5, 'oktaMax': 7, 'altitude': 2500, 'presenceCB': False, 'presenceTCU': False})

I want to create a piece of code that will look in each dictionary from the properties tuple and return me TRUE if the code value is either BKN and OVC. In addition to that, if TRUE I would like to look into the altitude only for BKN and OVC and check if these values are less than 1500.

Now I’m not really afraid of the IF statements, but at the moment, after some Google searches, I’m stuck in getting those specific items out of the dictionaries and eventually connecting these items with the altitude values.

Any help or suggestion will be greatly appreciated!

Source: Python Questions

LEAVE A COMMENT