I have a nested for loop but I can't for the life of me figure out how to transform it to a nested list comprehension. I don't seem to understand how nested list comps work, so if you could add explanation as well that would be extremely helpful.
Here is the data structure from which I'm trying to extract with the loop (It's for a marketing API):
list_of_orders = [{'Campaign ID': 1234, 'Orders': [{'Order ID': 0001, ...}, {'Order ID': 0002, ...}, ...]}, {'Campaign ID': 5678, 'Orders': [{...}, ...]}, ...]
Here is the loop:
order_ids = []
for i in list_of_orders:
for order in i.get('Orders'):
order_ids.append(str(order.get('Order ID')))
How could I - and should I - transform this into a list comp? Is that faster / more pythonic / a better practice?