Creating a concatenated list via list comprehension

Viewed 19

I'm working with the following code where pages refers to a list of strings and get_film_links is a function which returns a list:

link_list = []
for page in pages:
    link_list += get_film_links(page)

When the above loop is complete, link_lists will return as a single list. I've been trying to create the same code by using a list comprehension. Using the following code, I end up creating a list of lists, rather than a single concatenated list as the original code does.

link_list = [get_film_links(page) for page in pages]

How can I adjust this list comprehension to create a single, concatenated list rather than a list of lists?

0 Answers
Related