s = ' This is a sentence with whitespace.
'
print('Strip leading whitespace: {}'.format(s.lstrip()))
print('Strip trailing whitespace: {}'.format(s.rstrip()))
print('Strip all whitespace: {}'.format(s.strip()))
# Output
# Strip leading whitespace: This is a sentence with whitespace.
# Strip trailing whitespace: This is a sentence with whitespace.
# Strip all whitespace: This is a sentence with whitespace.
def remove_witespace(data_of_string):
string = ""
for char in data_of_string:
if " " not in char:
string = string + char
return string
print(remove_witespace("python is amazing programming language"))