Python5 min read

Python Strings

Work with text data in Python using strings.

Emily Davis
December 18, 2025
0.0k0

Master text handling.

String Basics

```python name = "Lisa" message = 'Hello from Chicago' long_text = """This is a multi-line string""" ```

String Operations

```python first = "John" last = "Smith"

Concatenate full_name = first + " " + last print(full_name) # John Smith

Repeat laugh = "ha" * 3 print(laugh) # hahaha ```

String Methods

```python text = "hello world"

print(text.upper()) # HELLO WORLD print(text.capitalize()) # Hello world print(text.replace("world", "Python")) # hello Python print(len(text)) # 11 ```

String Formatting

```python name = "Tom" age = 25

F-strings (best way) message = f"My name is {name}, I'm {age}" print(message) ```

Remember

- Use f-strings for formatting - Strings are immutable - Many useful methods available

#Python#Beginner#Strings