String Manipulation
String Manipulation
18. startswith() Returns True if the string starts with the substring otherwise False.
>>st='Hello All'
>>st.startswith('H')
>>True
19. endswith() Returns True if the string ends with the substring otherwise False.
>>'abcdef'.endswith('ab')
>>False
20. title() It returns a title-cased version of the string where all words starts with
uppercase characters and all remaining letters are in lowercase.
>>'all is 78well'.title()
>>'All Is 78Well'
21. istitle() Returns True if the string has the title case, i.e the first letter of each
word in upper case, while the rest of the letter in lowercase, False
otherwise.
22. join() joins a string or character after each member of the string iterator, i.e a
string based sequence
<string>.join(<string iterable>)
23. swapcase() Returns a copy of the string <str> with upper case characters
converted to lowercase and vice versa.
>>'Hello All'.swapcase()
>>'hELLO aLL'
24. split() The split() method splits a string into a list.
>>st='All is well'
>>st.split()
>>['All', 'is', 'well']
>>st.split('is')
>>['All ', ' well']
25. partition() The partition method splits the string at the first occurrence of
separator ad returns a tuple containing three items:
a. The part before the separator
b. The separator itself
c. The part after the separator
>>st='All is well'
>>st.partition('is')
>>('All ', 'is', ' well')