Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35107 > unrolled thread
| Started by | Vlastimil Brom <vlastimil.brom@gmail.com> |
|---|---|
| First post | 2012-12-19 13:38 +0100 |
| Last post | 2012-12-19 13:38 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: calculation on lists Vlastimil Brom <vlastimil.brom@gmail.com> - 2012-12-19 13:38 +0100
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
|---|---|
| Date | 2012-12-19 13:38 +0100 |
| Subject | Re: calculation on lists |
| Message-ID | <mailman.1045.1355920717.29569.python-list@python.org> |
2012/12/19 loïc Lauréote <laureote-loic@hotmail.fr>: hi, I have a question, is there a tool to calculate on list ? something like : >a= [1,1,1,1] >b = [5,9,8,4] >c = a+b*a >print c >[6,10,9,5] Thx ====== Hi, for such simpler cases, you may try list comprehensions and probably the zip(...) function >>> [a+b*a for a,b in zip([1,1,1,1], [5,9,8,4])] [6, 10, 9, 5] >>> hth, vbr
Back to top | Article view | comp.lang.python
csiph-web