python - Get combinations of words lists -


I am trying to write a small script (bash or python) which will combine the word lists into formats The output is as follows.

  list 1 | List 2 Like list 3 Big | Truck Hate | Medium | Cars | Short |  

and return results similar to the following:

  Like big mid-mikes like big trucks like big cars like small cars like medium cars Hate small truck like small cars like big cars hate big hatred medium hate small hatred big truck hate big cars hate hate middle truck hate middle car hate small truck hate small cars big truck big cars middle truck middle cars small truck small Cars Trucks  

Note that the list of words to be in the same order that they have come

you can be done in dragon very easily.

<['Trucks',' car '] sub-23 = [' '' '' ',' '' hate ''] list 2 = ['Big', 'medium', 'short'] list 3 = ['truck', 'car']. Join x (x) for x in ['.join (x)] itertools.product (list2, list3)] for x in Itertools.product (list1, list2 + sub23)] res = list1 + Sub12 + sub23 + list3 Print Res

Output: <'' like ',' Hate ',' Like Big ',' Like Michael ',' Little Like ',' Choice Big Trucks, like 'big cars',' like Michael trucks', 'like Michael Cars',' like small trucks', 'like small cars',' hate big ',' hate medium ',' hate small 'Hate Big Trucks, Hate Big Cars, Hate Medium Truck, Hate Model Car, Hate Sm L truck, het small cars, big trucks, big cars, medium trucks, 'medium car', 'small truck', 'small cars', 'truck', 'car']

P: The logic distribution behind this "weird" is to say the least that you can give a better answer by providing the real logic behind it :)


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -