-
-
Save parzibyte/f6999c17ad8fec084647d966e59f0e89 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 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