Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 27, 2022 02:34
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/f6999c17ad8fec084647d966e59f0e89 to your computer and use it in GitHub Desktop.
Save parzibyte/f6999c17ad8fec084647d966e59f0e89 to your computer and use it in GitHub Desktop.
def contar(entrada):
entrada = "".join(entrada.split(",")).upper()
ultima_letra = entrada[0]
conteo = 0
letras = ""
conteos = ""
indice = 0
for letra in entrada:
if letra != ultima_letra:
letras += ultima_letra + " "
conteos += str(conteo) + " "
conteo = 1
ultima_letra = letra
else:
conteo += 1
if indice+1 >= len(entrada):
letras += ultima_letra+" "
conteos += str(conteo) + " "
indice += 1
return letras, conteos
entrada = "E,E,e,E,E,d,E,E,D,c,C,E,E,B,E,E,a,E,A,E,g,E,G,E,f,E,f"
letras, conteos = contar(entrada)
print(letras)
print(conteos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment