GH avatar Bite 8. Rotate string characters

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!

628 out of 653 users completed this Bite.
Will you be Pythonista #629 to crack this Bite?
It takes an average of ~34 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 3.5 on a 1-10 difficulty scale.
» You can do it! 😌

Login and get coding
We use Python 3.7