← Back to challenges

Wrap Around

PythonHardstringsformattinglanguage_fundamentals

Instructions

Create a function to reproduce the wrap around effect shown:

Examples

wrap_around("Hello, World!", 2) ➞ "llo, World!He"

wrap_around("From what I gathered", -4) ➞ "eredFrom what I gath"

wrap_around("Excelsior", 30) ➞ "elsiorExc"

wrap_around("Nonscience", -116) ➞ "cienceNons"

Notes

  • The offset can be negative.
  • The offset can be greater than the length of string.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.