Justin Park wrote:
Suppose I have a list.
a = list()
And suppose allowed digits as the element are 1,2,3,4,5.
What can I do in order to iterate over all possible values for each element?
For instance, the sequence of the list I want to have would be
[1,1,1,1,1]
[1,1,1,1,2]
[1,1,1,1,3]
....
[5,5,5,5,4]
[5,5,5,5,5]
How can I make it happen?
Thanks,
Justin.
http://docs.python.org/library/itertools.html#itertools.product
from itertools import product
for item in product([1, 2], repeat=2):
print item
--
http://mail.python.org/mailman/listinfo/python-list