Combinatorial of elements in Python?

Sebastian Bassi sbassi at clubdelarazon.org
Wed Aug 15 15:39:16 CEST 2007


On 8/15/07, Wildemar Wildenburger <wildemar at freakmail.de> wrote:
> Oh but it is:
> >>> ADictionary={"one":["A","B","C","D"],"two":["H","I"]}
> >>> result = set()
> >>> for one in ADictionary["one"]:
> ...     for two in ADictionary["two"]:
> ...         result.add(one + two)

That was easy :)
What about extending it for N elements inside the dictionary? Sounds
like a work for a recursive function.

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D


More information about the Python-list mailing list