Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python: list comprehensions

numbers = [1,2,3,4,5,6,7,8]

greater_than_4 = [number for number in numbers if number > 4]


def shorter_than_X(strings, max_length):
    return [string for string in strings if len(string) < max_length]
Source by google.github.io #
 
PREVIOUS NEXT
Tagged: #list #comprehensions
ADD COMMENT
Topic
Name
2+5 =