Problem Description
Problem Solution
1. Take a string from the user and store it in a variable.
2. Pass the string as an argument to a function.
3. In the function, split the string.
4. Then add the last character to the middle part of the string which is in turn added to the first character.
5. Print the modified string.
6. Exit.
Algorithm:
1. User must enter a string and store it in a variable.
2. This string is passed as an argument to a function.
3. In the function, using string slicing, the string is first split into three parts which is the last character, middle part and the first character of the string.
4. These three parts are then concatenated using the + operator.
5. The modified string is then printed.CODING ARENA
def change(string):
return string[-1:] + string[1:-1] + string[:1]
string=input()
print(change(string))
Test Case 1
Input (stdin)eLab is an Auto Evaluation Tool
Expected OutputlLab is an Auto Evaluation Tooe
Test Case 2
Input (stdin)Indian is our country with diverse culture
Expected Outputendian is our country with diverse culturI
No comments:
Post a Comment