The strip() removes whitespace from the beginning or the end:
a = " Hello, World! "
print(a.strip()) # returns "Hello, World!"-----------------------------------------------------------------------------------
lower()/upper() returns the string in lower/upper case:a = "Hello, World!"
print(a.lower())
print(a.lower())
print(a.upper())
--------------------------------------------------------------------------------
split() divides the string into substrings if it finds instances of the separator:it is case sensitive, returns list,removes the word given in () from string.
a = "Hello, World!"
b = a.split("W")
print(b)
output =>
['Hello, ', 'orld!']
------------------------------------------------------------------------------------------------
To check if a certain phrase or character is present in a string, we can use the keywords
in or not in.
0 Comments