On Jan 16, 11:33 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of breal > > Sent: Wednesday, January 16, 2008 2:15 PM > > To: [EMAIL PROTECTED] > > Subject: Creating unique combinations from lists > > > I have three lists... for instance > > > a = ['big', 'small', 'medium']; > > b = ['old', 'new']; > > c = ['blue', 'green']; > > > I want to take those and end up with all of the combinations they > > create like the following lists > > ['big', 'old', 'blue'] > > ['small', 'old', 'blue'] > > ['medium', 'old', 'blue'] > > ['big', 'old', 'green'] > > ['small', 'old', 'green'] > > ['medium', 'small', 'green'] > > ['big', 'new', 'blue'] > > ['small', 'new', 'blue'] > > ['medium', 'new', 'blue'] > > ['big', 'new', 'green'] > > ['small', 'new', 'green'] > > ['medium', 'new', 'green' ] > > > I could do nested for ... in loops, but was looking for a Pythonic way > > to do this. Ideas? > > http://www.python.org/dev/peps/pep-0202/
Thanks for the reply. I never realized you could use list comprehension like this... AWESOME! -- http://mail.python.org/mailman/listinfo/python-list