samedi 11 septembre 2021

How to associate items of one list with items of another list with a condition in Python?

I have two lists and I want to print the item of the first list and the item of the second list based on a condition. For instance, I want to print the languages associated with the use of proofing tools and the language associate with the use of translation tools. I don't know how to include the condition. How to print without repeating the same language? My code so far is below:

tools=['translation;proofing','proofing','translation', 'language learning;proofing']
languages=['catalan;English', 'italian', 'french, german', 'english, portuguese']
for i in range(len(tools)):
    for j in tools:
        if "proofing" in j:
            print(languages[i])

My output should be something like:

Proofing: catalan, English, italian, portuguese

Translation: catalan, English, french, german

Aucun commentaire:

Enregistrer un commentaire