Python String – Python Programming

Python String is identified as a contiguous set of characters represented in the quotation marks. Python allows either pair of a single 'Single Quote String' or double quotes "Double Quote String"

'Single Quote String' is the same as "Double Quote String".

Python String Example
Photo by Alexas Fotos from Pexels

Like several alternative well-liked programming languages, strings in Python are arrays of bytes representing Unicode characters. However, Python doesn’t have a character data type, one character is just a string with a length of one.

Declaring Strings in Python

x = 'Single'
y = "Double"
print(x,y)

Note – The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition Operator. For example −

x = 'Study Gyaan'

print(x)
print(x[0])
print(x[0:5])
print(x[6:])
print(x*2)
print(x+'.com')

This will create an Output Like This

>>> print(x)
Study Gyaan
>>> print(x[0])
S
>>> print(x[0:5])
Study
>>> print(x[6:])
Gyaan
>>> print(x*2)
Study GyaanStudy Gyaan
>>> print(x+'.com')
Study Gyaan.com
Python String Video Tutorial

Whats Next – Python List

Share