Question about permutations (itertools)

Xavier Ho contact at xavierho.com
Mon May 31 10:17:49 EDT 2010


> >>> list(combinations_with_replacement('01',3))
> ('0', '0', '0')
> ('0', '0', '1')
> ('0', '1', '1')
> ('1', '1', '1')
>
> Is it possible to get combinations_with_replacement to return numbers
> rather than strings? (see above)
>

>>> list(combinations_with_replacement(range(0,2), 3))
[(0, 0, 0), (0, 0, 1), (0, 1, 1), (1, 1, 1)]


Hopefully that'll give you some ideas.

Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100601/a94c83ca/attachment-0001.html>


More information about the Python-list mailing list