The two basic operators of strings are: ‘+’ and ‘*’.
We have used these operators as arithmetic operators for addition and multiplication respectively. But when used with strings, ‘+’ operator performs concatenation rather than addition and ‘*’ operator performs replication rather than multiplication.
Concatenation– Concatenation means that ‘+’ sign joins two strings and prints it.
s='python' a='point' print(s+a)
Replication– To use ‘*’ operator with strings, we need two type of operands- a string and a number. The string operand tells the string to be replicated and the number operand tells the number of times it is to be repeated.
s=" Hi" a=3 print(s*a)
Output- Hi Hi Hi
There are two membership operators for string:- in and not in.
in- Returns True if a character or a string exists in the given string, false otherwise.
s="pythonpoint" print("n" in s)
not in- Returns True if a character or a string does not exist in the given string, false otherwise.
s="pythonpoint" print("z" not in s)
This is all about basic operations on string in python.