9. Python String Methods: split, strip and join

Publié le: 08 October 2026
sur la chaîne: Xavier Chee
131
1

WHAT THIS COVERS
(a) Splitting a string with split(): how to write the call, where the separator goes, what the method returns, and how to access a specific piece by its index. Understanding the data type of each piece, converting a string to a number using float(), and assigning each piece its own variable name in a single line.

(b) Removing spaces with strip(): why two strings that look identical when printed might not be equal, exactly which characters strip() removes, and how it handles spaces inside a string.

(c) lstrip() and rstrip(): modifying only one end of a string. Using strip() with an argument: choosing which characters to remove, how Python interprets the characters you provide, and why this can inadvertently strip more of a file name than intended.

(d) Checking how a string begins or ends with startswith() and endswith(): what a prefix is, what these methods return, using them in a loop to filter file names from a list, and how to check for multiple prefixes in a single call.

(e) Replacing text with replace(): its two primary arguments, how many matches it swaps by default, using the optional third argument to limit replacements, and removing a piece of text (like a unit of measurement) by replacing it with an empty string.

(f) Joining strings with join(): acting as the exact opposite of split(), why its syntax can feel backward at first glance, where the separator goes, and understanding the TypeError Python raises when the list contains numbers.

CHAPTERS
0:00 What you will be able to do
0:50 Why text data needs cleaning
1:44 Splitting a string with split()
3:03 Removing spaces with strip()
3:53 The one rule for every string method
4:21 lstrip(), rstrip() and strip() with characters
5:27 startswith() and endswith()
6:45 Replacing text with replace()
8:02 Joining strings with join()
8:57 A complete example: cleaning messy lines of text
10:06 Summary

THE COURSE
Every snippet here can be run in the scratchpad beside the lesson, in your browser, with nothing to install:
https://mscphm.github.io/bridging-cou...

Previous lesson: Python Read and Write Files, sys.argv
Link:    • 8. Python Input and Output: Read and Write...  

Next lesson: keeping related data and functions together with classes and objects.
Link:    • 10. Python Object-Oriented Programming I: ...  


Sur cette page du site, vous pouvez voir la vidéo en ligne 9. Python String Methods: split, strip and join durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Xavier Chee 08 October 2026, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 131 fois et il a aimé 1 téléspectateurs. Bon visionnage!