Python, working with list comprehensions

I have such code:

a = [[1, 1], [2, 1], [3, 0]]

I want to get two lists, the first contains elements of 'a', where a[][1] = 1, and the second - elements where a[][1] = 0. So

first_list = [[1, 1], [2, 1]] 

second_list = [[3, 0]]. 

I can do such thing with two list comprehension:

first_list = [i for i in a if i[1] == 1]

second_list = [i for i in a if i[1] == 0]

But maybe exists other (more pythonic, or shorter) way to do this? Thanks for your answers.

5
задан Björn Pollex 27 May 2011 в 07:57
поделиться