list comprehension examples

>>> listofnumbers = [ x for x in range(10) ]
>>> listofnumbers
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

>>> multiplesofthree = [ x for x in range(10) if x % 3 == 0 ]
>>> multiplesofthree
[0, 3, 6, 9]

>>> x=1
>>> y=1
>>> z=1
>>> n=2
>>> print ([[a,b,c] for a in range(0,x+1) for b in range(0,y+1) for c in range(0,z+1) if a + b + c != n ])
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]