String Quotations

SinglelineΒ 
strings
'Β 
'Β 
orΒ 
"Β 
"
MultilineΒ 
strings
Β 
(3Β 
singleΒ 
quotesΒ 
toΒ 
openΒ 
andΒ 
close)
'''
sentences
'''
var1 = "value1"
var2 = 'value2'

var3 = '''
value3
'''
var1 = "Strings in Python"
var2 = 'Strings in python'
var3 = '''
Multiline
string in
Python'''
print(var1)
print(var2)
print(var3)

Escaping (\)

ToΒ 
insertΒ 
charactersΒ 
thatΒ 
areΒ 
notΒ 
allowedΒ 
andΒ 
raiseΒ 
anΒ 
errorΒ 
inΒ 
aΒ 
string,Β 
weΒ 
useΒ 
anΒ 
escapeΒ 
character.
AnΒ 
escapeΒ 
characterΒ 
isΒ 
aΒ 
backslashΒ 
\
Β 
followedΒ 
byΒ 
theΒ 
characterΒ 
thatΒ 
isΒ 
toΒ 
beΒ 
inserted.Β 
PythonΒ 
ignoresΒ 
theΒ 
characterΒ 
afterΒ 
it.
print("Best programming language is "Python".")
print("Best programming language is \"Python\".")

New line (\n)

ToΒ 
breakΒ 
theΒ 
stringΒ 
toΒ 
aΒ 
newΒ 
line,Β 
weΒ 
useΒ 
\n
Β 
beforeΒ 
theΒ 
characterΒ 
fromΒ 
whereΒ 
weΒ 
wantΒ 
toΒ 
breakΒ 
theΒ 
string.
print("Hello\nWorld")

Tab space (\t)

ToΒ 
giveΒ 
4Β 
spacesΒ 
orΒ 
aΒ 
tabΒ 
afterΒ 
aΒ 
word,Β 
weΒ 
useΒ 
\t
.
print("Hello Hi \t World")

Concatenation

JoinsΒ 
twoΒ 
orΒ 
moreΒ 
stringsΒ 
together.
TheΒ 
+Β 
operatorΒ 
isΒ 
usedΒ 
toΒ 
concatenateΒ 
2Β 
orΒ 
moreΒ 
strings.
a = "Hello"
b = "World"
c = a + b
print(c)

String Repetition

TheΒ 
repetitionΒ 
operatorΒ 
isΒ 
denotedΒ 
byΒ 
aΒ 
'*'
Β 
symbolΒ 
andΒ 
isΒ 
usedΒ 
toΒ 
repeatΒ 
strings.
YouΒ 
canΒ 
multiplyΒ 
aΒ 
stringΒ 
withΒ 
anΒ 
integer,Β 
andΒ 
itΒ 
willΒ 
beΒ 
repeatedΒ 
thatΒ 
manyΒ 
times.
str = "Python"
print(str*3)