Text shows up everywhere in real programs: names, messages, files, and user input. You will pinpoint characters by position, carve out substrings with slicing, clean and reshape text using built-in methods, and search, split, and join strings to pull out exactly the pieces you need.
Overview
Syllabus
Python String Indexing
- Print Product Code Characters by Index
- Reach the Last Character Two Ways
- Find the Middle of the Code
- Build a Short Code From Ends
Mastering String Slicing
- Slice a Filename Prefix and Suffix
- Extract the Invoice Number
- Print the Final Three Characters
- Print Every Second Character
- Reverse the Filename with Slicing
Reshaping Strings with Methods
- Show Case Changes Keep Original
- Trim the Padded Input
- Chain the Cleanup Methods
- Strip Separators from a Phone Number
Searching and Splitting Strings
- Check the Email for At
- Locate the At and Split the Address
- Check Both Edges of the Address
- Split the Tag String
- Rejoin the Tags with a Separator