Answers for "python Which method can be used to remove any whitespace from both the beginning and ending of a string?"

4

remove all whitespace from string python

import re
s = 'n t this is a string   with a lot of whitespacet'
s = re.sub('s+', '', s)
Posted by: Guest on August-03-2020
0

remove trailing white space python string

vals_inp=input() 
list_set = list(vals_inp) 
vals = [x for x in list_set if x != ' '] 
set_vals = set(vals)
Posted by: Guest on October-24-2021

Code answers related to "python Which method can be used to remove any whitespace from both the beginning and ending of a string?"

Python Answers by Framework

Browse Popular Code Answers by Language