Created
April 21, 2020 19:35
-
-
Save abidtkg/c0703f31537948e449443f5abfde1e0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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