I have a tuple in Python that stores the translation of some English words in German that looks like this:
[("mother", ["Mutter"]), ("and", ["und"]), ("father", ["Vater"]), ("I", ["ich", "mich"]),("not", ["nicht"]), ("at", ["dort", "da"]), ("home", ["Haus", "Zuhause"]), ("now", ["jetzt"])]
As you can see, some of the English words have 2 possible translations in German
I need to create an Output which automatically gives all possible translations of a sentence. E.g.
[’ Vater ich nicht dort Haus jetzt ’,
’Vater ich nicht dort Zuhause jetzt ’,
’Vater ich nicht da Haus jetzt ’,
’Vater ich nicht da Zuhause jetzt ’,
’Vater mich nicht dort Haus jetzt ’,
’Vater mich nicht dort Zuhause jetzt ’,
’Vater mich nicht da Haus jetzt ’,
’Vater mich nicht da Zuhause jetzt ’]
My first idea was to store the tuple in two different lists like this:
english = []
german = []
for pair in wordlist:
english.append(pair[0])
for item in pair[1]: german.append(item)
but I am not sure how to get the second German translation into another list, and how to make the Cartesian product of those lists, so that they appear in the right place
Could somebody help me with what do do here?