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
- Characters, ord & chr Tricks
- Count Letters with a Frequency Table
- Palindrome Checks Done Right
- Split, Strip & Rejoin Words