Next →

What is a String?

A string is a sequence of characters — basically, text. In Python, you create a string by placing text between quotation marks:

Example:

‍message = "Hello, world!"

You can use either single or double quotes:

Example:

greeting = 'Hi there!'

String Operations

Python lets you do all kinds of useful things with strings.

Concatenation: You can join strings using the + operator.
Example:

first_name = "Alice"
last_name = "Smith"
full_name = first_name + " " + last_name

String Length: Use len() to find how many characters are in a string:
len(full_name) returns 11.

Changing Case:
full_name.upper() gives "ALICE SMITH"
full_name.lower() gives "alice smith"

Why Strings Matter in Analytics

Working with strings is essential when dealing with things like column names, filtering by category, or formatting results. You'll often need to clean or manipulate text data before analyzing it.