These are some of the basic built-in string functions in python :
-
len(string):
len
or length function is used to find the character length of any string.len
returns a number and it takes a string as an argument.
>>> s = "Hello" >>> print (len(s)) Output: 5
-
find(subString): In case you want to find the position of any character or of a subString within any given string, you can use the
find
function.
>>> s = "Hello" >>> ss = "He" >>> print (s.find(ss)) Output: 0
-
string_name.lower():
lower()
function is used to convert all the uppercase characters present in a string into lowercase.
>>> print ("Hello, World".lower()); Output: hello, world
-
string_name.upper():
upper()
is used to turn all the characters in a string to uppercase.
>>> print ("Hello, World".upper()); Output: HELLO, WORLD