Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34258 > unrolled thread
| Started by | Daniel Fetchinson <fetchinson@googlemail.com> |
|---|---|
| First post | 2012-12-04 22:25 +0100 |
| Last post | 2012-12-04 22:25 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
assign only first few items of a tuple/list Daniel Fetchinson <fetchinson@googlemail.com> - 2012-12-04 22:25 +0100
| From | Daniel Fetchinson <fetchinson@googlemail.com> |
|---|---|
| Date | 2012-12-04 22:25 +0100 |
| Subject | assign only first few items of a tuple/list |
| Message-ID | <mailman.478.1354656321.29569.python-list@python.org> |
Hi folks, I swear I used to know this but can't find it anywhere. Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. I'd like to assign the first two items to two variables, something like, a, b, _ = x but the above will not work, of course, but what is the common idiom for this that does? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown
Back to top | Article view | comp.lang.python
csiph-web