To remove the whitespaces and trailing spaces from the string, Python providies strip([str]) built-in function. This function returns a copy of the string after removing whitespaces if present. Otherwise returns original string.
string = ” javatpoint “
string2 = ” javatpoint “
string3 = ” javatpoint”
print(string)
print(string2)
print(string3)
print(“After stripping all have placed in a sequence:”)
print(string.strip())
print(string2.strip())
print(string3.strip())
javatpoint
javatpoint
javatpoint