slicing
name [0:4]
‘Mich’
stride
# Get every second element. The elments on index 1, 3, 5 ... name [::2]
incorporate slicing with strde
# Get every second element in the range from index 0 to index 4 name [0:5:2]
Concatenate
# Concatenate two strings statement =name +"is the best"
Print strings 3 times
# Print the string for 3 times 3* "Michael Jackson"
back slash
New line escape sequence
print(“ Michael Jackson \n is the best” )
Michael jackson
is the best
back slash ‘t’
New line escape sequence
print(“ Michael Jackson \n is the best” )
Michael jackson
is the best
upper
# Convert all the characters in string to upper case
a = "Thriller is the sixth studio album"
print ("before upper:", a)
b = a. upper ()
print ("after upper:", b)replace
# Replace the old substring with the new target substring is the segment has been found in the string
a= "Michael Jackson is the best"
b=a.replace ('Michael', 'Janet')
bfind
# Find the substring in the string. Only the index of the first elment of substring in string will be the output
name ="Michael Jackson"
name .find ('el')