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]
More Related Contents:
- Using lambda function in python
- Python 2.7.10: Using LAMBDA and LOGICAL operators in DICT to choose a case
- What do lambda function closures capture?
- How are lambdas useful? [closed]
- How to understand closure in a lambda?
- Finding the average of a list
- Python lambda closure scoping
- Is it pythonic: naming lambdas
- Syntax behind sorted(key=lambda: …)
- List comprehension vs. lambda + filter
- python max function using ‘key’ and lambda expression
- Tkinter lambda function
- Can Python pickle lambda functions?
- Can a lambda function call itself recursively in Python?
- Assignment inside lambda expression in Python
- What is key=lambda
- List comprehension and lambdas in Python [duplicate]
- E731 do not assign a lambda expression, use a def
- Why doesn’t print work in a lambda?
- lambda function don’t closure the parameter in Python? [duplicate]
- Python pandas – filter rows after groupby
- Lifetime of object in lambda connected to pyqtSignal
- Check if two Python functions are equal
- Use value of variable in lambda expression [duplicate]
- Why do parentheses in a lambda function cause syntax error on Python 3? [duplicate]
- Why use lambda functions?
- Dictionary With Lambda Values Updates All Entries
- Is there a way to perform “if” in python’s lambda? [duplicate]
- What exactly is “lambda” in Python? [duplicate]
- PyQt5 button lambda variable becomes boolean [duplicate]