-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5368 from marcoatrs/main
Reto #30 - Python
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
Retos/Reto #30 - EL TECLADO T9 [Media]/python/marcoatrs.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
teclado_t9 = [" ", ",.?", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] | ||
|
||
def convertir_pulsaciones(texto: str) -> str: | ||
pulsaciones = texto.split("-") | ||
salida = "" | ||
for pulsacion in pulsaciones: | ||
if not pulsacion.isdigit(): | ||
print("Formato incorrecto") | ||
return | ||
if not all([c == pulsacion[0] for c in pulsacion]): | ||
print(f"La pulsacion {pulsacion} no es igual") | ||
salida += teclado_t9[int(pulsacion[0])][len(pulsacion) - 1] | ||
return salida | ||
|
||
print(convertir_pulsaciones("6-2-777-222-666-0-2-66-8-666-66-444-666")) |