Write a Dart program remove specified a character from a non-empty string using index of a character.

Code:

import 'dart:io';

void main() {
  stdout.write('Input word : ');
  String word = stdin.readLineSync();
  stdout.write('index to be removed : ');
  int index = int.parse(stdin.readLineSync());

  word = word.substring(0, index) + word.substring(index + 1);
  print(word);
}


Output:

Comments

Popular posts from this blog

Write a Dart program to convert from celsius degrees to Kelvin and Fahrenheit.

Write a Dart program to create a new string from a given string (length 1 or more ) with the first character added at the front and back.