I've got two lists:
synonymes = ['verb1', 'verb2', 'verb3']
phrases = ['blabla verb blabla', 'blibli verb blibli', 'verb bloblo bloblo']
and I would like to combine them to obtain this result in another list:
liste = ['blabla verb1 blabla','blabla verb2 blabla', ... 'verb3 bloblo bloblo']
the following code works but it's not very elegant, and I would like to give the 2 lists as entries of the function that's doing this job, which is impossible with this solution:
while j < len(synonymes):
liste.append("blabla "+synonymes[j]+" blabla")
liste.append("blibli "+synonymes[j]+" blibli")
liste.append(synonymes[j]+" bloblo bloblo")
j+=1
I can change the structure of these two lists if need be, as long as I can obtain this final list
What would be a proper way to do so in python?
Thanks!
EDIT : to make myself clearer, here is the exact output that I want:
["blabla verb1 blabla", "blabla verb2 blabla", "blabla verb3 blabla", "blibli verb1 blabla", "blibli verb2 blibli", "blibli verb3 blibli", "verb1 bloblo bloblo", "verb2 bloblo bloblo", "verb3 bloblo bloblo"]
With the length of synonymes and phrases both variable.
Copyright Notice:Content Author:「Benjamin BB」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50188344/python-combined-lists-iteration