How can I use list comprehension for this case:
>>> a = 'A'
>>> lista = [1, 2, 8, 5, 10]
>>> l = [a, num for num in lista if num%2 == 0]
File "<stdin>", line 1
l = [a, num for num in lista if num%2 == 0]
^
SyntaxError: invalid syntax
As you can see this syntax is not possible. My idea was to create a new list only with the even numbers of lista
and a
.
['A', 2, 8, 10]
How can I do this with list comprehension ?