Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 21, 2022 18:33
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 parzibyte/a7dfc64bec79835aeea4cba5f5f3e067 to your computer and use it in GitHub Desktop.
Save parzibyte/a7dfc64bec79835aeea4cba5f5f3e067 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment