Skip to content

Instantly share code, notes, and snippets.

Last active Dec 10, 2018
What would you like to do?
RotarCadena created by parzibyte -
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