Python for Data Engineers
Back to Python Fundamentals

Python Strings

Learn powerful string manipulation techniques that help in cleaning messy text data.

17 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. String Literals and Length — Quotes, multi-line string syntax, and the built-in len function are introduced.
  2. Indexing and Slicing — Square bracket indexing with positive and negative numbers and slice range notation are explained.
  3. Escape Sequences — Backslash usage for escaping quotes, inserting backslashes, and adding newlines is demonstrated.
  4. Formatted Strings — F-strings are introduced as a modern approach to interpolate variables and expressions at runtime.
  5. Case and Whitespace Methods — Dot notation is introduced alongside methods for casing transforms and whitespace trimming.
  6. Search, Replace, and Membership — Methods for locating, replacing, and checking substring existence with boolean operators are presented.
PDF notes

Frequently asked questions

What is the difference between a function like len() and a method like .upper()?

A function like len() is a standalone general-purpose routine called independently, whereas a method is attached to an object type and invoked via dot notation.

What does str.find() return if the search string is not found?

It returns -1 to indicate the substring is absent, rather than raising an error.

When should I use .find() versus the in operator?

Use the in operator when you only need a boolean True/False existence check, and use .find() when you need the integer starting position of the substring.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.