I want to append items to an existing list that have been generated by list comprehension as individual lists.
source = [1,2,3,4,5]
I want the result to look like [[2], [4]]
I have tried the following (and other crazy combos of '[]' and '()' and gotten nowhere)...
target = []
target.append([r for r in source if r == 2 or r == 4])
print(target)
[[2, 4]]
target = []
target.append([[r] for r in source if r == 2 or r == 4])
print(target)
[[[2], [4]]]
target = []
target.append([r] for r in source if r == 2 or r == 4)
print(target)
[<generator object <genexpr> at 0x0000022F1986E4C8>]