[melbourne-pug] array matching

Teguh Iskanto tiskanto at gmail.com
Fri Apr 30 08:23:51 CEST 2010


Or you can use zip , like this :
>>> A = [1,3,5,7]
>>> B = [2,4,6,8]
>>> C = zip(A,B)
>>> C
[(1, 2), (3, 4), (5, 6), (7, 8)]

>>> C[0]
(1, 2)

>>> C[1]
(3, 4)

hope this helps,
Rgds
Teguh Iskanto

On Fri, Apr 30, 2010 at 11:11 AM, Filip <filipz at 3g.nec.com.au> wrote:

>  You could use dictionary of lists
>
>
>
> test = {
>
>             A: [1, 3],
>
>             B: [2, 4]
>
> }
>
>
>
> print test[A]
>
> [1, 3]
>
>
>
> test[A].append(5)
>
>
>
> print test[A]
>
> [1, 3, 5]
>
>
>
> Cheers,
>
>
>
> Fil
>  ------------------------------
>
> *From:* melbourne-pug-bounces+filipz=3g.nec.com.au at python.org [mailto:
> melbourne-pug-bounces+filipz <melbourne-pug-bounces%2Bfilipz>=
> 3g.nec.com.au at python.org] *On Behalf Of *Bill Jordan
> *Sent:* Friday, 30 April 2010 3:58 AM
> *To:* python-dev at python.org; python-list at python.org; bangpypers at python.org;
> melbourne-pug at python.org; portland at python.org
> *Subject:* [melbourne-pug] array matching
>
>
>
> Hey guys,
>
>
>
> I am sorry if this is not the right list to post some questions. I have a
> simple question please and would appreciate some answers as I am new to
> Python.
>
>
>
> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]]
>
> I want to arrang this array in different arrays so each one will have what
> is attached to. For example I want the output:
>
>
>
> A =[1,3] and B=[2,4]
>
>
>
> Thanks,
>
> Bill
>
>
>
> _______________________________________________
> melbourne-pug mailing list
> melbourne-pug at python.org
> http://mail.python.org/mailman/listinfo/melbourne-pug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20100430/fbac1ba3/attachment-0001.html>


More information about the melbourne-pug mailing list