Python Itertools permutations with strings
问题 i want to use itertools permutations for strings instead of just letters. import itertools lst = list(permutations(("red","blue"),3)) #This returns [] I know i can do something like: a = list(permutations(range(3),3)) for i in range(len(a)): a[i] = list(map(lambda x: 'red' if x==0 else 'blue' if x==1 else 'green',a[i])) EDIT: I want to key in this as my input, and get this as my output input: ("red","red","blue") output: [(’red’, ’red’, ’red’), (’red’, ’red’, ’blue’),\ (’red’, ’blue’, ’red’),