Python one-line "for" expression [duplicate]
The keyword you're looking for is list comprehensions:
>>> x = [1, 2, 3, 4, 5]
>>> y = [2*a for a in x if a % 2 == 1]
>>> print(y)
[2, 6, 10]
for item in array: array2.append (item)
Or, in this case:
array2 += array
If you really only need to add the items in one array to another, the '+' operator is already overloaded to do that, incidentally:
a1 = [1,2,3,4,5]
a2 = [6,7,8,9]
a1 + a2
--> [1, 2, 3, 4, 5, 6, 7, 8, 9]