From dd7828292b5be96bfaae8856e5a5f27cc5aa23f2 Mon Sep 17 00:00:00 2001 From: Marco Torres Date: Wed, 11 Oct 2023 18:45:37 -0700 Subject: [PATCH] Reto #30 - Python --- .../python/marcoatrs.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Retos/Reto #30 - EL TECLADO T9 [Media]/python/marcoatrs.py diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/python/marcoatrs.py b/Retos/Reto #30 - EL TECLADO T9 [Media]/python/marcoatrs.py new file mode 100644 index 0000000000..e740fc1978 --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/python/marcoatrs.py @@ -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"))