Created
June 14, 2018 13:32
-
-
Save acwoss/097d69852407ca02871d8c7aa4cb26fd to your computer and use it in GitHub Desktop.
BubblyClearComputergraphics created by acwoss - https://repl.it/@acwoss/BubblyClearComputergraphics
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
palavra1 = {'palavra': 'sim', 'positivo': 0} | |
palavra2 = {'palavra': 'não', 'positivo': 0} | |
palavras = [palavra1, palavra2] | |
resultado1 = filter(lambda termo: termo['palavra'] == 'sim', palavras) | |
resultado2 = [termo for termo in palavras if termo['palavra'] == 'sim'] | |
resultado3 = (termo for termo in palavras if termo['palavra'] == 'sim') | |
print('Utilizando filter:', list(resultado1)) | |
print('Utilizando list comprehension:', resultado2) | |
print('Utilizando generator comprehension:', list(resultado3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment