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’), (’red’, ’blue’, ’blue’), (’blue’, ’red’, ’red’), \
(’blue’, ’red’, ’blue’), (’blue’, ’blue’, ’red’), (’blue’, ’blue’, ’blue’)]
[]is because you're asking for length-3 permutations in a list of length-2 -- there aren't any!