Python strings:-
a set of characters in between quotation marks are called as strings.We can use single quotes or double quotes to represent strings.As:-
We can access individual characters using indexing and a range of characters using slicing.Negative indexing is allowed in python( [-1] will be treated as last character and so on). As shown here:-
String Operations:-
There are many operations that can be performed with string are given below:-
1. Concatenation:-
The ( + ) operator is used to concatenate two or more string. Using parentheses we can also concatenate two strings. The asterisk ( * ) is the repetition operator.As shown here:-
Updating string:-
we can update a string as shown here.:-
~~~~
>>> name = "Hello"
>>> name[:6] + " Python..!!"
'hello Python..!!'
~~~~
Membership test:-
We can test if a sub string exists within a string or not, using the keyword “in” & “not in” .
As shown here:-