Created
May 16, 2018 12:55
-
-
Save David-Lor/3068b5fcf22c2866c466477ddf88cdbf to your computer and use it in GitHub Desktop.
python frases diccionario
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
def contiene_hola(): | |
print("el texto contiene 'hola'") | |
def contiene_que_tal(): | |
print("el texto contiene 'que tal'") | |
def contiene_hasta_luego(): | |
print("el texto contiene 'hasta luego'") | |
diccionario = { | |
"hola" : contiene_hola, | |
"que tal" : contiene_que_tal, | |
"hasta luego" : contiene_hasta_luego | |
} | |
def analizar(texto): | |
for expresion in diccionario.keys(): | |
if expresion in texto: | |
diccionario[expresion]() | |
analizar("hola, que tal estas") | |
analizar("yo muy bien, y tu que tal") | |
analizar("yo genial") | |
analizar("vale, hasta luego!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment