Skip to content

Instantly share code, notes, and snippets.

@abidtkg
Created April 21, 2020 19:35
Show Gist options
  • Save abidtkg/c0703f31537948e449443f5abfde1e0f to your computer and use it in GitHub Desktop.
Save abidtkg/c0703f31537948e449443f5abfde1e0f to your computer and use it in GitHub Desktop.
# FILTER PEOPLE FUNCTION DEFINED
def filterPeople(peoples):
# CREATED EMPTRY ARRAY FOR INSERTING FILTERD NAME
filteredName = []
# LOOP THROUGH THE WHOLE ARRAY
for people in peoples:
# LOGIC APPLY USING IF
if(people[1] >= 12):
# PUSH THE NAME INTO THE ARRAY
filteredName.append(people[0])
# RETURN THE ARRAY AS FUNCTION RETURN FOR FURTHER USE
return filteredName
# REAL LIFE DATA USING A METHOD
peoples = filterPeople([['abid', 10], ['john', 14], ['anis', 18], ['doe', 10]])
# FIANALLY PRINT THE ARRAY OF THE FILTERD DATA
print(peoples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment