Use a list comprehension with the "if" filter to extract these values in the list less than the specified value:
def smaller_than(sequence, value):
return [item for item in sequence if item < value]
I recommend giving variables more generic names, because this code will work for any sequence, regardless of the type of elements in the sequence (provided, of course, that the comparisons are valid for the corresponding type).
>>> smaller_than([1,2,3,4,5,6,7,8], 5)
[1, 2, 3, 4]
>>> smaller_than('abcdefg', 'd')
['a', 'b', 'c']
>>> smaller_than(set([1.34, 33.12, 1.0, 11.72, 10]), 10)
[1.0, 1.34]
NB However, there is already a similar answer, I would prefer to declare a function instead of binding a lambda expression.