0Pricing
Competitive Programming Academy · Lesson

Split, Strip & Rejoin Words

Tokenize sentences for word problems.

From Sentence to Words

Word problems usually start by breaking a line into tokens. Python makes this easy with split, and that is your first move. ✂️

split() With No Argument

Calling split() with no argument breaks on any run of whitespace and ignores leading or trailing spaces. It is the safe default.

print('  hi   there '.split())  # ['hi', 'there']

All lessons in this course

  1. Characters, ord & chr Tricks
  2. Count Letters with a Frequency Table
  3. Palindrome Checks Done Right
  4. Split, Strip & Rejoin Words
← Back to Competitive Programming Academy