Python 3.5Code walkthrough9 parts

Strings

Clean and split text, the first step of every text model.

Loading your progress…Next: 3.6 Comprehensions

In this lesson9 parts

  1. 01One review, a list of words
  2. 02Indexing and slicing a string
  3. 03A step, a reversed string, and a palindrome
  4. 04Strings are immutable, so methods return a new string
  5. 05strip, and chaining methods
  6. 06Searching a string: in, find and count
  7. 07replace, split and join
  8. 08A first tokeniser
  9. 09Recap, your challenge, and what's next

Key terms

The words this lesson introduces, each in one line. The module’s glossary collects them all.

chaining
Calling a method on the value the previous method returned: review.strip().lower().
string
An immutable sequence of characters, indexed and sliced like a list.
token
One of the pieces tokenisation produces. Our tokeniser's tokens are lowercase words without punctuation.
tokenisation
Splitting text into pieces. Language models split into subword pieces; the video's tokeniser splits on whitespace.

Quiz 5 questions

Your first pick on each question is the one that counts, and a right one earns a coin. Getting one wrong here is how the lesson sticks.

Practice

Problems to solve in your own notebook. Each states the problem, not the steps: working out the steps is the exercise. Level A applies the lesson, B combines it with earlier ones, C stretches it.

The self-checking notebook for this lesson is Notebook 3 · Strings and Comprehensions.

Common mistakes

What you will see when it goes wrong, why it happens, and the fix.

Where it’s used

Where this lesson’s ideas turn up in real work.