assign only first few items of a tuple/list
Daniel Fetchinson
fetchinson at googlemail.com
Tue Dec 4 16:25:18 EST 2012
More information about the Python-list mailing list
Tue Dec 4 16:25:18 EST 2012
- Previous message (by thread): The Select Group- Raleigh, NC
- Next message (by thread): assign only first few items of a tuple/list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): The Select Group- Raleigh, NC
- Next message (by thread): assign only first few items of a tuple/list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list