1.capitalize() :-
It converts the first character to upper case
example:-
>>> astring='ankit'
>>> astring.capitalize()
'Ankit'
2.count() :-
It gives the number of times a specified value occurs in a string
example:-
>>> astring='ankit dagar'
>>> astring.count(a)
>>> astring.count('a')
3
3.endswith():-
It gives true if the string ends with the specified value
example:-
>>> filename = "example.txt"
>>> filename.endswith(".txt")
True
4.find() :-
It searches the string for a specified value and returns the position of where it was found
>>> astring='ankit dagar'
>>> astring.find('k')
2
5.format() :-
It formats the specified values in a string
>>> name = 'Ankit'
>>> age=22
>>> result="my name is {},i am {} year old".format(name,age)
>>> result
'my name is Ankit,i am 22 year old'
6.index() :-
It searches the string for a specified value and returns the position of where it was found
example:-
>>> astring='ANKIT DAGAR'
>>>> astring.index('K')
2
7.isdecimal() :-
It gives True if all characters in the string are decimals
>>> astring='ANKIT DAGAR'
>>>> astring.isdecimal()
False
8.isdigit() :-
It gives True if all characters in the string are digits
>>> astring='ANKIT DAGAR'
>>> astring.isdigit()
False
9.islower() :-
It gives True if all characters in the string are lower case
>>> astring='ANKIT DAGAR'
>>> astring.islower()
False
10.isnumeric() :-
It gives True if all characters in the string are numeric
>>> astring='ANKIT DAGAR'
>>> astring.isnumeric()
False
11.isspace() :-
It gives True if all characters in the string are whitespaces
>>> astring='ANKIT DAGAR'
>>> astring.isspace()
False
12.istitle() :-
It gives True if the string follows the rules of a title
>>> astring='ANKIT DAGAR'
>>> astring.istitle()
False
13.isupper() :-
It gives True if all characters in the string are upper case
>>> astring='ANKIT DAGAR'
>>> astring.isupper()
True
14.lower() :-
It converts a string into lower case
>>> astring='ANKIT DAGAR'
>>> astring.lower()
'ankit dagar'
References
GeeksforGeeks
W3Schools
freecodecamp
Top comments (0)