Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python for loop one line

>>> x = [1, 2, 3, 4, 5]
>>> y = [2*a for a in x if a % 2 == 1]
>>> print(y)
[2, 6, 10]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #loop #line
ADD COMMENT
Topic
Name
6+7 =