Ch-10 (String Manipulation)
Ch-10 (String Manipulation)
String Manipulation
String Manipulation: String is a sequence of characters, which is enclosed between either
single('') or double quotes(""), python treats both single and double quotes same.
Output:
Teapot
Teapot
Output:
TeapotTeapotTeapot
123123
TeapotTeapotTeapotTeapot
Output:
True
False
True
String Slices : Part of string containing some contiguous characters from the string.
0 1 2 3 4 5
a= P Y T H O N
-6 -5 -4 -3 -2 -1
print( a[0 : 5] )
print( a[2 : 6] )
print( a[ : 3] )
print( a[-4 : -1] )
print( a[1 : 6 : 2] )
Output:
PYTHO
THON
PYT
THO
YHN