Learn list comprehension with detailed explanation and example
expression means what you want to
append
in the list.
Create a list of even numbers from existing list
Output: [12, 8, 2, 6, 90]
Output: [3, 1.1, 25, 2.1]
Output: ['A', 'B', 'O', 'M']
Output:
['A', 'B', 144, 225, 49, 4, 9, 'O', 'M']
Output:
[[0, 1, 2], [0, 1, 2], [0, 1, 2]]
Learn more