Answers for "python filters"

9

filter list with python

scores = [70, 60, 80, 90, 50]
filtered = filter(lambda score: score >= 70, scores)

print(list(filtered))

# Output:
[70, 80, 90]
Posted by: Guest on January-12-2021
1

python filter

ages = [5, 12, 17, 18, 24, 32]
def myFunc(x):
  if x < 18:
    return False
  else:
    return True
  
adults = filter(myFunc, ages)
for x in adults:
  print(x)     		# 18 24 32
Posted by: Guest on May-13-2021

Python Answers by Framework

Browse Popular Code Answers by Language