Skip to content

Instantly share code, notes, and snippets.

@David-Lor
Created May 16, 2018 12:55
Show Gist options
  • Save David-Lor/3068b5fcf22c2866c466477ddf88cdbf to your computer and use it in GitHub Desktop.
Save David-Lor/3068b5fcf22c2866c466477ddf88cdbf to your computer and use it in GitHub Desktop.
python frases diccionario
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