Menu
Coddy logo textTech

Splitting Text into Words

Part of the Logic & Flow section of Coddy's Dart journey — lesson 53 of 65.

challenge icon

Challenge

Easy

Continuing your text analyzer project, you'll now implement the word splitting functionality. This step will break down your text into individual words, creating a foundation for word-level analysis in the upcoming lessons.

  1. Use the textToAnalyze variable from your previous setup
  2. Use the totalCharacters variable from your character counting step
  3. Split the text into individual words using the split() method with a space character as the delimiter
  4. Store the resulting list of words in a variable called wordList
  5. Display the word splitting analysis results in the exact format shown below
  6. Show the original text, character count, and the list of words with proper formatting

For example, if your text analyzer was set up with "Hello world!", your program should output:

Text Analysis Tool - Word Splitting
====================================
Analyzing text: "Hello world!"
Total characters: 12
====================================
Word Splitting Results:
Words found: [Hello, world!]
====================================
Word splitting completed successfully.

If your text analyzer was set up with "The quick brown fox", your program should output:

Text Analysis Tool - Word Splitting
====================================
Analyzing text: "The quick brown fox"
Total characters: 19
====================================
Word Splitting Results:
Words found: [The, quick, brown, fox]
====================================
Word splitting completed successfully.

If your text analyzer was set up with "Programming is fun!", your program should output:

Text Analysis Tool - Word Splitting
====================================
Analyzing text: "Programming is fun!"
Total characters: 19
====================================
Word Splitting Results:
Words found: [Programming, is, fun!]
====================================
Word splitting completed successfully.

Your program should use the split(' ') method on the string to break it into individual words separated by spaces. The resulting list will contain each word as a separate string element, which will be used for word counting and analysis in the next lessons. Note that punctuation marks will remain attached to the words they appear with.

Try it yourself

import 'dart:io';

void main() {
  String? textToAnalyze = stdin.readLineSync();
  
  int totalCharacters = textToAnalyze!.length;
  
  print('Text Analysis Tool - Character Count');
  print('====================================');
  print('Analyzing text: "$textToAnalyze"');
  print('====================================');
  print('Character Analysis Results:');
  print('Total characters (including spaces): $totalCharacters');
  print('====================================');
  print('Character counting completed successfully.');
}

All lessons in Logic & Flow