-
-
Save parzibyte/fce550613e7fd127fbfc1731f783e8d2 to your computer and use it in GitHub Desktop.
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 expandir(datos): | |
salida = "" | |
# Hacer un ciclo "de 2 en 2", es decir, vamos en 0, 2, 4, 6, etcétera | |
for i in range(0, len(datos), 2): | |
# Extraer la base y cantidad | |
par = datos[i:i+2] | |
letra = par[0] | |
cantidad = int(par[1]) | |
# Expandimos la base multiplicando la cadena | |
letra_expandida = letra * cantidad | |
# La agregamos al resultado final | |
salida += letra_expandida | |
return salida | |
print(expandir("a1e4o6z9")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment