Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save naemazam/aedde225f3cb24cc7f45ada5295f491a to your computer and use it in GitHub Desktop.
Save naemazam/aedde225f3cb24cc7f45ada5295f491a to your computer and use it in GitHub Desktop.
''' Enter a string s and an integer n in the two lines respectively, and define a
function to move the string s to the right by n bits, and to the left when n is a
negative number. ‪‬‮‭‫
If s is an empty string ‘ ', output ‘ ' regardless of n.
[sample input]
For example, s ='123456 '
n=3
[sample output]
Output result: 456123
'''
try:
user_input = input("S= ")
n = int(input("n= "))
sliced_left = user_input[:n]
sliced_right = user_input[n:]
print(sliced_right+sliced_left)
except ValueError:
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment