wagtail / guide

A website to teach Wagtail CMS to content editors, moderators and administrators.
https://guide.wagtail.org
BSD 3-Clause "New" or "Revised" License
32 stars 26 forks source link

Python programming task #1 #297

Closed activus-d closed 1 year ago

activus-d commented 1 year ago

Given a list of locales (["en", "is", "en_GB"]), and a list of versions (["latest", "4.1.x", "4.2.x"]), generate a list of all possible combinations of locales and versions.

locales = ["en", "is", "en_GB"]
versions = ["latest", "4.1.x", "4.2.x"]

def generate_combinations():
    return ["en-latest", "en-4.1.x", "is-latest", "is-4.1.x"]

This helps practice:

activus-d commented 1 year ago

@thibaudcolas @allcaps @Stormheg kindly review my solution to the task:

def generate_combinations(locales, versions):
    combined_list = []
    for locale in locales:
        for version in versions:
            combined_list.append(f"{locale}-{version}")
    return combined_list