Soeren Sonnenburg wrote:
> Hi all,
>
> Just having started with python, I feel that simple array operations '*'
> and '+' don't do multiplication/addition but instead extend/join an
> array:
>
> a=[1,2,3]
> >>> b=[4,5,6]
> >>> a+b
> [1, 2, 3, 4, 5, 6]
>
> instead of what I would have expected:
> [5,7,9]

To get what you expected, use

[x + y for (x, y) in zip(a, b)]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to