SyntaxFix
Write A Post
Hire A Developer
Questions
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]