Filter in Python


Code Example


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("You are Adult : ", x)


Screenshot :



Quiz Level 1

Quiz Level 2


Request Me

Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python