Explain any 5 string methods in
python?
Ans.-
1.) replace(old,new[,count]) :-Replaces
all the occurrences of substring ‘old’ with ‘new’ in the string.
If ‘count’ is defined then only ‘count’ number of occurrences
of ‘old’ will be replaced with ‘new’.
Old= substring to be replaced
New= substring that will replace the old
Count= number of occurrences of old that will be replaced
with new.
2.) lower() :-converts all the
characters of the string
to lowercase.
3.) upper() :-converts
all the characters of the string to uppercase.
4.)capitalize() :-
returns the string with first character capitalized and rest of the character
in lowercase.
5.) len(string) :-return
the length of given string