Python Strings and Text
Slice, search, clean and format text like a working developer.
Almost every program handles text: names, emails, log lines, CSV rows, settings files and receipts. You will index and slice strings (backwards too), see why a string never changes in place, and learn how characters become Unicode code points and UTF-8 bytes, with ord, chr, encode, decode and the errors a wrong codec raises. Then you will clean input with string methods, choose between find, index and in, compare and sort text by code point, split lines apart and join them back together, and format numbers into aligned output and multi-line text. The course ends with realistic tools: a keyword router, a word counter, a slug maker, a palindrome checker, a receipt formatter, a byte-budget truncator and a caesar cipher.
What you will learn
- String slicing
- Unicode and UTF-8
- String methods
- Searching text
- Sorting text
- split and join
- f-string formatting
- Text cleaning
- Parsing
Lessons
- 1
Strings Are Sequences
Index, slice and loop over text, learn why a string never changes in place, and see how characters become code points and UTF-8 bytes.
16 exercises
- 2
String Methods
Change case, trim, replace, search, compare and sort text with the methods every Python developer uses daily, and know when find, index or in is the right search.
13 exercises
- 3
split and join
Break text into lists of pieces, parse simple records and settings by hand, and glue pieces back into one string.
12 exercises
- 4
Formatting Output
Control decimals, thousands separators, padding and alignment with f-string format specs, and lay out multi-line text and tables.
14 exercises
- 5
Putting It Together
Build small text tools: a keyword router, a word counter, a slug maker, a palindrome checker, a receipt formatter, a byte-budget truncator and a caesar cipher.
10 exercises
How you practice
You practice in the browser and every exercise gives you feedback right away. This course uses these formats:
- Code exercise: 26
- Predict the output: 10
- Type the answer: 7
- Fix the bug: 7
- Fill in the blank: 6
- Match the pairs: 3
- Select all that apply: 2
- Multiple choice: 2
- Spot the bug: 1
- Reorder lines: 1
Aligned to
- Data Collections - Tuples, Dictionaries, Lists, and Strings
- 3.4Operate with strings
- Strings
- 3.1Understand machine representation of characters
- 3.2Operate on strings
- 3.3Employ built-in string methods
- Software Development Fundamentals
- SDF-Data-StructuresFundamental Data Structures
Proto Node Labs is not affiliated with or endorsed by Python Institute and ACM / IEEE-CS / AAAI. Exam names are trademarks of their owners.