Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active Dec 10, 2018
Embed
What would you like to do?
RotarCadena created by parzibyte - https://repl.it/@parzibyte/RotarCadena
"""
Rotar cadena en Python
@author parzibyte
"""
cadena = "Hola"
rotada = ""
rotaciones = 2
for letra in cadena:
# Sacar su número
representacion_entera = ord(letra)
# Concatenar
rotada += chr(representacion_entera + rotaciones)
print("La cadena {} al ser rotada {} posiciones, se convierte en {}".format(
cadena, rotaciones, rotada))
# Salida:
# La cadena Hola al ser rotada 2 posiciones, se convierte en Jqnc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment