Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-321

Whitespace Token Count

Problem

The simplest tokenizer splits text on runs of whitespace.

Given a text string, return the number of whitespace-separated tokens.

Hint

Python's split with no arguments handles arbitrary whitespace runs.

Test cases

case 1
in: ["hello world"]
expected: 2
case 2
in: [" a b "]
expected: 2
case 3
in: [""]
expected: 0
Starter codePython
def whitespace_token_count(text):
    # Your code here
    pass

3 test cases · run your code against them in the editor