Created
October 27, 2021 09:55
-
-
Save naemazam/aedde225f3cb24cc7f45ada5295f491a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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