Python Slicing Rotate String
# Python3.x Python String Slicing and Rotation
[ Python3 Examples](#)
Given a string, extract a specified number of characters from the head or tail, then reverse and concatenate them.
## Example
```python
def rotate(input,d):
Lfirst = input[0 : d]
Lsecond = input[d :]
Rfirst = input[0 : len(input)-d]
Rsecond = input[len(input)-d : ]
print("Head slice rotation : ", (Lsecond + Lfirst))
print("Tail slice rotation : ", (Rsecond + Rfirst))
if __name__ == " __main__ ":
input = ''
d=2 # Extract two characters
rotate(input,d)
Executing the above code produces the following output:
Head slice rotation : noobRu
Tail slice rotation : obRuno
[ Python3 Examples](#)
YouTip