We use Python 3.6

go back Level: Beginner (img: BG / score: 2) level Bite 8. Rotate string characters

482 out of 503 users completed this Bite ...
Will you be Pythonista #483 to crack this Bite?
Average Bite difficulty 1-10 rating: 3.39
» You can do it! 😌

Write a function that rotates characters in a string, in both directions:

  • if n is positive move characters from beginning to end, e.g.: rotate('hello', 2) would return llohe
  • if n is negative move characters to the start of the string, e.g.: rotate('hello', -2) would return lohel

See tests for more info. Have fun!

Github login button