Write a Dart program to create a new string from a given string where the first and last characters will change their positions.
Test Data:
Python
Sample Output:
nythoP
Python
Sample Output:
nythoP
Code:
import 'dart:io';
void main() {
stdout.write('Input word : ');
String word = stdin.readLineSync();
String result;
result = word[word.length - 1] + word.substring(1, word.length - 1) + word[0];
print(result);
}
Output:
Comments
Post a Comment