[Tutor] Creating a list from other lists

Walter Prins wprins at gmail.com
Mon Oct 22 12:54:01 CEST 2012

Hi Saad,

On 22 October 2012 11:37, Steven D'Aprano <steve at pearwood.info> wrote:
> On 22/10/12 21:21, Saad Javed wrote:
>> I'm trying to create a list (L) from items of different lists (a, b, c)
>> but
>> in a specific order (L = [[a1, b1, c1], [a2, b2, c2]...etc])
>> L = []
>> a = [1, 2, 3, 4]
>> b = ['a', 'b', 'c', 'd']
>> c = [2009, 2010, 2011, 2012]
>> for x, y , z in zip(a, b, c):
>> L.extend([x, y, z])
>> print L
> This is not your code, because that gives a SyntaxError. Where is
> the indentation? Indentation is required in Python, if you leave it
> out, your code will not work correctly. You should have either:

Just to note: For me your (Saad's) indentation showed perfectly fine
on GMail.  I'm note sure why Steven didn't see it (I think he reads
only plaintext email), so I'd guess perhaps your email included both
HTML and plain text parts and the plain text part perhaps had the
indentation stripped out and the HTML did not.  Anyway point being,
it's best to post plain text if you're emailing unless you absolutely
must use HTML, certainly this is the best way for this mailing list.



More information about the Tutor mailing list