Re: [Tutor] Need help combining elements of a list of lists

2018-07-10 Thread Mats Wichmann
On 07/10/2018 09:09 PM, Steven D'Aprano wrote: > On Tue, Jul 10, 2018 at 09:46:57PM -0500, Jim wrote: > >> Say I have a list like ltrs and I want to print out all the possible 3 >> letter combinations. I want to combine letters from each inner list but >> not combine any letters within the inner

Re: [Tutor] Need help combining elements of a list of lists

2018-07-10 Thread David Rock
> On Jul 10, 2018, at 22:04, David Rock wrote: > >> On Jul 10, 2018, at 21:46, Jim wrote: >> >> ltrs = [['A', 'B'], ['C', 'D', 'E'], ['F', 'G', 'H', 'I']] > > A fairly straightforward way is to use nested loops: > for l in ltrs[0]: > ... for j in ltrs[1]: > ... for k in ltrs[2]: >

Re: [Tutor] Need help combining elements of a list of lists

2018-07-10 Thread Steven D'Aprano
On Tue, Jul 10, 2018 at 09:46:57PM -0500, Jim wrote: > Say I have a list like ltrs and I want to print out all the possible 3 > letter combinations. I want to combine letters from each inner list but > not combine any letters within the inner list itself. So ACF and ADF > would be ok but ABC wo

Re: [Tutor] Need help combining elements of a list of lists

2018-07-10 Thread David Rock
> On Jul 10, 2018, at 21:46, Jim wrote: > > ltrs = [['A', 'B'], ['C', 'D', 'E'], ['F', 'G', 'H', 'I']] A fairly straightforward way is to use nested loops: >>> for l in ltrs[0]: ... for j in ltrs[1]: ... for k in ltrs[2]: ... print l,j,k A C F A C G A C H A C I A D F A D G A D H A

[Tutor] Need help combining elements of a list of lists

2018-07-10 Thread Jim
Say I have a list like ltrs and I want to print out all the possible 3 letter combinations. I want to combine letters from each inner list but not combine any letters within the inner list itself. So ACF and ADF would be ok but ABC would not. I can lay it out manually and see the pattern, I ca