Input :
a = [{'layer': 'OVC', 'ceiling': '020', 'type': None}]
b = [{'layer': 'BKN', 'ceiling': '010', 'type': None}, {'layer': 'OVC', 'ceiling': '020', 'type': None}]
c = [{'layer': 'BKN', 'ceiling': '010', 'type': None}, {'layer': 'BKN', 'ceiling': '020', 'type': None},{'layer': 'OVC', 'ceiling': '030', 'type': None}]
d = [a,b,c] 
results1 = []
results2 = [] 
for i in range(0,len(d)):
 res1=[]
 res2=[]
 cloudstf = d[i]
 if not cloudstf:
  res1 = "-9999"
  res2 = "-9999"
  results1.append(res1)
  results2.append(res2)
 elif len(d[i])==1:
  res1 = d[i]["layer"]
  res2 = d[i]["ceiling"]
  results1.append([res1])
  results2.append([res2])
 elif len(d[i])>1:
  for k in range(0,len(d)):
   res1 = d[i][k]["layer"]
   res2 = d[i][k]["ceiling"]
   results1.append([res1])
   results2.append([res2])
 cloudtf = []
cloud_group_layer = results1
cloud_group_height = results2 
print(cloud_group_height)
print(cloud_group_layer)
Instead of getting:
cloud_group_layer = [['OVC'], ['BKN'], ['OVC'], ['BKN'],['BKN'],['OVC']]
cloud_group_height = [['020'], ['010'], ['020'], ['010'],['020'],['030']]
How can I get:
cloud_group_layer = [['OVC'], ['BKN','OVC'], ['BKN','BKN','OVC']]
cloud_group_height = [['020'], ['010','020'], ['010','020','030']]
Where the layer and height are group by how many. The code is all there just a little confusion in the syntax. Or it could be a Tuple because of the heights.
You might get this error while running it and its because of the indexing:
Traceback (most recent call last): File "main.py", line 22, in <module> res1 = d[i]["layer"] TypeError: list indices must be integers or slices, not str
 
     
    