Created
August 11, 2016 08:00
-
-
Save jherrlin/8710afcecd9dfceab927360851bef64e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from pprint import pprint as pp # Good looking print | |
animals = [ | |
{'name': 'Fluffykins', 'species': 'rabbit'}, | |
{'name': 'Caro', 'species': 'dog'}, | |
{'name': 'Hamilton', 'species': 'dog'}, | |
{'name': 'Harold', 'species': 'fish'}, | |
{'name': 'Ursula', 'species': 'cat'}, | |
{'name': 'Jimmy', 'species': 'fish'} | |
] | |
dogs_filter = filter(lambda x: x['species'] == 'dog', animals) # Do the filtering | |
print(type(dogs_filter)) # Print type | |
pp(list(dogs_filter)) # Convert to list and print items |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment