I have an list/array, lets call it x, and I want to create a new list/array, lets call this one z, out of elements from x that match a
x
z
Using a list comprehension is considered "Pythonic":
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] z = [i for i in x if i < 5] print z
Output
[1, 2, 3, 4]