DS 1501 · Lesson 17 of 24
Instructor: Corey Schafer21m
Sign in to watchClean, tokenize, search, and format messy real-world textual datasets using Python strings. What you will learn: • String immutability: why s[0] = 'X' raises TypeError and string methods always return a NEW string. • Indexing, slicing, concatenation, repetition, and character classification (isalpha, isdigit, isalnum, isspace). • Essential cleaning & parsing methods: strip/lstrip/rstrip, lower/upper/title, replace, find vs index, count, split(), and ','.join(tokens). • Advanced f-string formatting for tables, aligned columns, percentages, and zero-padded IDs. University Outline Mapping: Class 17 · CO3 · Reading: Chapter 8 (deitel) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 17 | CO3 | Reading: Deitel Chapter 8 Common Exam Traps on Strings: • ' hi '.strip() returns 'hi' — if you write line.strip() without rebinding (line = line.strip()), line stays unchanged! • s.find('z') returns -1 when missing; s.index('z') raises ValueError. • 'a b\tc'.split() (no arg) collapses runs of whitespace -> ['a', 'b', 'c'], while ','.join(words) takes only strings.
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community