flatten_list

flatten_list(nested_list: list[list[str] | str]) list[str][source][source]

Flatten a nested list of strings.

This function takes a list that may contain both strings and lists of strings, and returns a single flat list containing all the strings.

Parameters:

nested_list (list[list[str] | str]) – A list containing strings and/or lists of strings.

Returns:

A flattened list containing all strings from the input.

Return type:

list[str]

Examples

>>> flatten_list(['a', ['b', 'c'], 'd'])
['a', 'b', 'c', 'd']