Loading video player…

Strings and Character Data in Python: Overview

In this course, you’ll learn about working with strings, which are objects that contain sequences of character data. Processing character data is integral to programming. It is a rare application that doesn’t need to manipulate strings to at least some extent.

Python provides a rich set of operators, functions, and methods for working with strings. When you’re finished this course, you’ll know how to:

  • Use operators with strings
  • Access and extract portions of strings
  • Use built-in Python functions with characters and strings
  • Use methods to manipulate and modify string data

You’ll also be introduced to two other Python objects used to represent raw byte data: the bytes and bytearray types.


Course Slides (PDF)

746.1 KB

Take the Quiz: Test your knowledge with our interactive “Python Strings and Character Data” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Python Strings and Character Data

Test your understanding of Python strings and character data.

00:01 Hi, I’m Chris Bailey from Real Python. I’ll be taking you through the course String and Character Data in Python. So, what will you learn in this tutorial?

00:12 You’ll learn how to use operators with strings, how to access and extract portions of a string. You’ll learn about the types of methods available to strings for manipulating and modifying string data.

00:27 And you’ll learn how to use two other Python objects to represent raw byte data—they are bytes and bytearray objects. Let me run through the table of contents and give you a heads up as to what’s going to be covered in this course.

00:41 This first video is an intro and a course overview. Then you’re going to dive right into using operators on strings.

00:51 You’ll learn about a few built-in functions that work with strings.

00:59 You’ll learn about string indexing and the syntax to access individual characters within a string. Then you’ll build on that syntax to accomplish string slicing, allowing you to select substrings of characters from your string. Next, you’ll learn about interpolating variables into a string.

01:18 This uses a Python feature called f-strings, introduced in Python 3.6. Then you’ll learn about how to modify strings. Even though strings as a type are immutable, there are ways around it. That then brings you into Section 2, which is all about built-in string methods.

01:37 You’ll learn some of the similarities and differences between functions and methods. Then you’ll start using some of those methods to do case conversion, converting your characters from upper and lowercase, and also title casing.

01:53 The next video is all about find and seek—finding substrings of characters within your strings.

02:04 Next, you’ll learn methods that allow you to do character classification to determine what are the contents of your strings.

02:17 String formatting is up next, where you’ll practice methods for reformatting your strings—centering and justifying, or replacing unwanted characters, or exchanging substrings.

02:33 And at the end of Section 2, you’ll learn about lists and tuples, and how to convert your string data into a list and vice versa. The third section is about bytes objects. There’ll be a bytes object overview, then you’ll learn about defining a literal bytes object.

02:57 After that, the other way to define a bytes object is to use the built-in bytes() function, and you’ll learn three different ways to apply that function.

03:08 Next, it’s operations on bytes objects. bytes objects are very similar to string objects, and you can use a lot of the same types of operators and methods just as you did with strings, with a few small differences. And finally, you’ll learn about bytearray objects and how they’re similar to bytes objects.

03:32 You’ll learn how to create them, and you’ll compare and contrast them with bytes objects. The very last video is a conclusion and course review.

03:45 All right, it’s time to get started with string operators.

Avatar image for jgbalbuena

jgbalbuena on Jan. 5, 2020

Hi, the audio sounds very bad, could you fix it?

Avatar image for Chris Bailey

Chris Bailey RP Team on Jan. 7, 2020

Hi @jgbalbuena, Is it only the audio for this lesson, or do you hear bad sound on other Real Python lessons? I have tested the current video lesson file and it seems to sound clear. Is there something specific that needs to be fixed?

Avatar image for munish259272

munish259272 on Jan. 22, 2020

I just started, it’s clear to me.

Avatar image for tanda

tanda on May 17, 2020

What editor or IDE are you using. I like the blue outlined help panels.

Avatar image for Chris Bailey

Chris Bailey RP Team on May 18, 2020

Hi @tanda,

I’m using the REPL replacement tool BPython. And I have details about it and links for more information at the bottom of the next lesson, in the text bellow the video.

Avatar image for tanda

tanda on May 18, 2020


Become a Member to join the conversation.