Skip to content

Instantly share code, notes, and snippets.

@larry852
Last active December 11, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larry852/fd24fa16e8b681811757620b5e9bfded to your computer and use it in GitHub Desktop.
Save larry852/fd24fa16e8b681811757620b5e9bfded to your computer and use it in GitHub Desktop.
Solucion "The Python Challenges el regreso Reto #1: phonewords"
def codificar(mensaje):
letras = '--abc-def-ghi-jkl-mno-pqrs-tuv-wxyz'
teclado = letras.split('-')
respuesta = ''
for letra in mensaje:
for index, tecla in enumerate(teclado):
if letra == ' ':
respuesta += ' '
break
elif tecla is not None and letra.lower() in tecla:
respuesta += str(index)
break
return respuesta
print("Underc0de.org --> " + codificar("Underc0de.org"))
print("$$$$$$Underc0de.org$$$$$$ --> " + codificar("$$$$$$Underc0de.org$$$$$$"))
print("Esto es una prueba --> " + codificar("Esto es una prueba"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment