Skip to main content

get_text_list

Converts a list of items into a human-readable string, joining elements with commas and a final separator word like 'and' or 'or'.

def get_text_list(
list_: list,
last_word: string = gettext_lazy("or")
) - > string

Converts a list of items into a human-readable string, separating items with commas and using a specific conjunction for the final element.

Parameters

NameTypeDescription
list_listThe collection of items to be formatted into a single string.
last_wordstring = gettext_lazy("or")The conjunction used to join the final element with the rest of the list, such as 'and' or 'or'.

Returns

TypeDescription
stringA formatted string containing all list elements joined by commas and the specified last word, or an empty string if the input list is empty.