Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

all permutation from 2 arrays python

>>> import itertools
>>> a = ['foo', 'bar', 'baz']
>>> b = ['x', 'y', 'z', 'w']

>>> for r in itertools.product(a, b): print r[0] + r[1]
foox
fooy
fooz
foow
barx
bary
barz
barw
bazx
bazy
bazz
bazw
Comment

all permutation from 2 arrays python


>>> import itertools
>>> map(''.join, itertools.chain(itertools.product(list1, list2), itertools.product(list2, list1)))
['squarered', 'squaregreen', 'circlered',
'circlegreen', 'trianglered', 'trianglegreen',
'redsquare', 'redcircle', 'redtriangle', 'greensquare',
'greencircle', 'greentriangle']

Comment

PREVIOUS NEXT
Code Example
Python :: python split string by tab 
Python :: remove first row of dataframe 
Python :: open image in numpy 
Python :: majority in array python 
Python :: count number of matrix islands python 
Python :: How to generate the power set of a given set, in Python? 
Python :: python pyautogui how to change the screenshot location 
Python :: array of random integers python 
Python :: if type is string python 
Python :: python how to get project location 
Python :: django makemigrations comand 
Python :: label size matplotlib 
Python :: find all nan columns pandas 
Python :: pytorch load model 
Python :: select closest number in array python 
Python :: django create app command 
Python :: how to get ipconfig from python 
Python :: python how to get number of strings in a list 
Python :: python key down 
Python :: save model pickle 
Python :: how to create correlation heatmap in python 
Python :: format integer to be money python 
Python :: web3py convert from wei to ether 
Python :: How to Add a Title to Seaborn Plots 
Python :: scroll to element python selenium 
Python :: convert text file into list 
Python :: python how much memory does a variable need 
Python :: get local timezone python 
Python :: python install libs 
Python :: how to play music on pygame 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =