Last active
December 11, 2017 04:52
-
-
Save larry852/fd24fa16e8b681811757620b5e9bfded to your computer and use it in GitHub Desktop.
Solucion "The Python Challenges el regreso Reto #1: phonewords"
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 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