8. Strings and Text#
Strings are sequences of characters, so many sequence ideas from lists and tuples also apply to text.
Strings as immutable sequences
String methods for cleaning and transforming text
Regular expressions for pattern matching
Dictionaries and counters for text analysis
Random text and Markov-style generation
Video
This overview introduces strings, string operations, and common string methods for working with text.
Python Tutorial for Beginners 2: Strings - Working with Textual Data by Corey Schafer
Learning Goals
By the end of this chapter, you will be able to:
Create, index, slice, and compare strings
Use string methods to clean, search, split, join, and format text
Use regular expressions to find and replace text patterns
Count words and summarize text with dictionaries and
CounterGenerate simple random text from word relationships