Take this example:
"something": {
"random": 0,
"bag": {
"papers": 0,
"pencils": 0
},
"PAINT": {
"COLORS": [
"A WHITE",
"B MAPLE",
"B LOTUS",
"A OLIVE"
],
"CANS": [
"SOMETHING"
]
}
Ignore everything and focus on the COLORS list in the PAINT dictionary... I want to print all colors that have the color A before them, as a code. In other words I want to print "A WHITE" and "A OLIVE". Here's what happens when I do this:
with open("somethings.json", "r") as f:
data = json.load(f)
print(data["something"]["PAINT"]["COLORS"])
This is the output:
["A WHITE", "B MAPLE", "B LOTUS", "A OLIVE"]
but like I said, I do not want that... I want only A colors to be printed... I also do not want THIS:
["A WHITE", "A OLIVE"]
the output that I really want (which is quite specific) is this:
OLIVE
WHITE
With line breaks (optional: AND in alphabetical order) that is the output that I want. So how can I print this output? is it possible without using any 'for' loops? This is a very specific question, would appreciate some help. Thanks -