Let's say, we have and list of objects in variable called "articles", each object has a member "tags" (which is simple list).
Expected output: all tags in all articles, joined in a single list.
In multiple lines, solution would be:
arr = []
for article in articles:
for tag in article.tags:
arr.append(tag)
Now, how can we write this in single line instead of 4?
This syntax is invalid:
arr = [tag for tag in article.tags for article in articles]
Thanks!