<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Zero Piraeus</b> <span dir="ltr"><<a href="mailto:schesis@gmail.com">schesis@gmail.com</a>></span><br>Date: Tue, Oct 23, 2012 at 11:14 AM<br>
Subject: Re: can we append a list with another list in Python ?<br>To: inshu chauhan <<a href="mailto:insideshoes@gmail.com">insideshoes@gmail.com</a>><br><br><br>:<br>
<div class="im"><br>
On 23 October 2012 05:01, inshu chauhan <<a href="mailto:insideshoes@gmail.com">insideshoes@gmail.com</a>> wrote:<br>
> this is because this makes a single list out of 2 lists.. but I want to retain both lists as lists within list....... I hope u got it ??<br>
><br>
> my problem is for example :<br>
><br>
> x = [1,2,3]<br>
> y = [10, 20, 30]<br>
><br>
> I want the output to be :<br>
><br>
> [[1,2,3], [10, 20, 30]] .. a list within list<br>
><br>
> then i want to process each list in the big list using another function ????<br>
<br>
</div>For the example above, you'd just do:<br>
<br>
>>> x = [1, 2, 3]<br>
<div class="im">>>> y = [10, 20, 30]<br>
</div>>>> z = [x, y]<br>
>>> z<br>
[[1, 2, 3], [10, 20, 30]]<br>
<br>
... but presumably there'll be more than two, and you're creating them<br>
in some kind of loop? In that case, append is fine. For example:<br>
<br>
>>> result = []<br>
>>> for word in "squee", "kapow", "vroom":<br>
... seq = list(word) # or whatever you're doing to create the list<br>
... result.append(seq)<br>
...<br>
>>> result<br>
[['s', 'q', 'u', 'e', 'e'], ['k', 'a', 'p', 'o', 'w'], ['v', 'r', 'o',<br>
'o', 'm']]<br>
<br>
By the way - you only replied to me. Do you mind if I forward this<br>
back to the list?<br>
<span class="HOEnZb"><font color="#888888"><br>
-[]z.<br>
</font></span></div><br>