Python Basics — Strings

less than 1 minute read

Strings

Strings are one of Python’s most used data types. Whether you’re processing text, building messages, or parsing data — you’ll work with strings constantly.

This chapter takes a deep dive into everything strings can do.

What You’ll Learn

Topic Description
String Creation & Indexing Creating strings and accessing characters
String Slicing Extracting substrings with slice notation
String Methods Complete reference of built-in methods
String Formatting Deep Dive Templates, textwrap, and advanced formatting
Regular Expressions Intro Pattern matching with the re module
Practice Exercises Test your skills

Quick Preview

message = "Hello, Python!"

print(message[0])        # H
print(message[-1])       # !
print(message[7:13])     # Python
print(message.upper())   # HELLO, PYTHON!
print(len(message))      # 14

Strings are immutable — once created, they can’t be changed in place. Every string operation returns a new string.


Start Learning: String Creation & Indexing →

Updated: