Python String

Let’s talk about this data type str which stands for strings.

A string is simply a piece of text for example a string can be written with quotation marks i.e ‘Hello World’.

We can also make strings with double quotes, this is also a valid string i.e. “Hello World”.

Python does not support character data type, one character is also treated as a string of length one.

x = "Hello World"
y = 'Python Coding'



Hello World
Python Coding

Multiple Line String

We can’t write a paragraph of multiple lines using single or double quotes, so there is a triple quotation method to write a big paragraph of multiple lines.

x = '''This is a big paragraph
by using triple qoutation
in Python.



This is big paragraph
by using triple qoutation
in Python.

**We also use escape characters in between big paragraphs.

Escape Characters

Backslash NotationDescription
\aBell or alert
\nnnOctal notation, where n is in the range 0.7
\rCarriage return
\vVertical tab
\xCharacter x
\xnnHexadecimal notation, where n is in the range 0.9, a.f, or A.F

Accessing Values in Strings

We can access characters or substring from a string using index number. This is also called String Slicing. For example:

x = 'Python'

print(x[0:4]) #start index : end index+1



String Concatenation

Adding two or more string is called String Concatenation. This only works with Strings, we can’t a string and a number.

Scroll to Top