Python – String

Strings in Python are identified as a contiguous set of characters represented in the quotation marks. Python allows either pair of single( ‘ Single Quote String  ‘) or double quotes( ” Double Quote String “). 

Declaring String 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')
Filed under: Python

No comment yet, add your voice below!


Leave a Reply