Python strings, start to finish: making one, reaching into it, changing it, searching it, and splitting it apart. Every line runs in real Python, typed on screen chapter by chapter.
0:00 Cold open: name.reverse() crashes, name[::-1] prints it backward
0:11 Make one: quotes, len(), a line of equals signs, and + to glue two strings together
1:14 Reach in: indexing, slicing, a step, and the IndexError at index 20
2:41 Change it: upper() returns a copy, item assignment is refused, rebinding fixes it
4:07 Find things: in, find, count, startswith, and a lowercase compare
5:19 Split and join: split() breaks a string apart, join() glues it back
6:23 Recap: strip, title, split, and slice, together in seven lines
Both one-minute cuts are already on the channel: the crash that opens this video is where
python-string-manipulation ends ( • Python String Manipulation : This Python S... ), and the IndexError in Reach in is where python-strings ends ( • String Indexing in 41 Seconds (Then an Error) ).
What is covered:
title = "The Realist" and len(title): quotes build a string, len counts every character
title[0], title[4], title[-1]: indexing from the front and from the back
title[0:3], title[4:], title[::2], title[::-1]: slicing, a step, and a reverse
title[20]: IndexError, string index out of range
title.upper() and title[0] = "t": a method hands back a copy, item assignment is refused
title = title.upper(): the fix, rebinding the name to the new string
raw.strip(), raw.replace(...): every method returns something new, raw itself never changes
"Real" in title, title.find("l"), title.count("e"), title.startswith("The"): searching without a loop
title.split(), "-".join(parts): breaking a string apart and gluing it back together
Subscribe to The Realist for full Python lessons built the same way, one program at a time.
Which string trick surprised you most, the slice that reverses it or the assignment that cannot? Say so below.
#Python #PythonStrings #LearnPython #PythonFullCourse #robot #stickmananimation #animation