Skip to content

Commit 692935c

Browse files
author
richie.p
committed
improve -Implemented the roate algorithm using string.
1 parent 304b398 commit 692935c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rotate.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def rotate_string(sequence: str, value: int) -> str:
2+
result = sequence + sequence
3+
4+
if value <= len(sequence):
5+
return result[value:value+len(sequence)]
6+
else:
7+
return resut[value-len(sequence):value]
8+

0 commit comments

Comments
 (0)