Combinatorial of elements in Python?

Mikael Olofsson mikael at isy.liu.se
Thu Aug 16 10:57:24 CEST 2007


Sebastian Bassi wrote:
> On 8/15/07, Mikael Olofsson <mikael at isy.liu.se> wrote:
>   
>> What is unclear here is in what order the keys should be visited. The
>> following assumes that the keys should be considered in alphanumeric order.
>>     
>
> Yes, my fault. The orden should be given by a string, like:
>
> DCDBA
> Using this dictionay.
> A={'A':['1','2'],'B':['4','5'],'C':['6','7','8'],'D':['9']}
>
> Should return:
>
> '96941'
> '97941'
> '97942'
> '96942'
> '98941'
> '98942'
> '96951'
> '97951'
> '97952'
> '96952'
> '98951'
> '98952'

OK, seems like you need to add a second argument to the function 
specifying this order. I leave that to you.

/MiO



More information about the Python-list mailing list