filmov
tv
How to Remove Whitespace from String in Python (5 Examples) | strip(), rstrip() & lstrip() Functions

Показать описание
Python code of this video:
my_string = " This sentence contains many redundant whitespaces !!! "
print(my_string)
print(my_string_1) # Print updated string
# "This sentence contains many redundant whitespaces !!!"
print(my_string_2) # Print updated string
# " This sentence contains many redundant whitespaces !!!"
print(my_string_3) # Print updated string
# "This sentence contains many redundant whitespaces !!! "
import re # Import regular expressions
print(my_string_4) # Print updated string
# " This sentence contains many redundant whitespaces !!! "
print(my_string_5) # Print updated string
# Thissentencecontainsmanyredundantwhitespaces!!!
Follow me on Social Media:
my_string = " This sentence contains many redundant whitespaces !!! "
print(my_string)
print(my_string_1) # Print updated string
# "This sentence contains many redundant whitespaces !!!"
print(my_string_2) # Print updated string
# " This sentence contains many redundant whitespaces !!!"
print(my_string_3) # Print updated string
# "This sentence contains many redundant whitespaces !!! "
import re # Import regular expressions
print(my_string_4) # Print updated string
# " This sentence contains many redundant whitespaces !!! "
print(my_string_5) # Print updated string
# Thissentencecontainsmanyredundantwhitespaces!!!
Follow me on Social Media: