Search⌘ K
AI Features

Strings

Explore Python strings, including their definition, concatenation methods, the use of special escape characters, and indexing techniques. Understand how to access and manipulate characters in strings safely and effectively.

Definition

A string is a sequence of characters enclosed in quotation marks.

In Python, you can use either single quotes or double quotes for strings. You can also insert single quotes inside double-quoted strings, and vice versa.

Python usually uses single quotes when printing out results.

There is no separate “character” data type in Python.

Python 3.5
print("Hello World")
print("Saynora, My Friend!")
print("This term is known as 'iceberg', your highness.")
print('And Tom said to me, "Eat while you are still young"')
...