Possible Duplicate:
All possible permutations of a set of lists in Python
I want to find every combination of different length character lists in Python. For example, I have the following lists which define possible characters in a string:
list1=['a','d','e','f','b']
list2=['h','s','c','v','e', 'u', '?', "^", "k"]
list3=['a','d]
list4=[',','4','u','t','R','x', ' ']
list5=['%','e','u','y']
And I want to find every combination of the lists in to the string, i.e. "aha,%", "dha,%", "eha,%".
One could simply use varied nested loops, but with many more lists this is not practical.
This seems like it should be a simple problem.