for i in range(0,(len(list))):
x = str(list[i]).strip(' ')
list[i] = x
string=' t e s t '
print(string.replace(' ',''))
string = "Welcome to Python"
new_str = "".join(string.split(" "))
print(new_str) # "WelcometoPython"
#If you want to remove LEADING and ENDING spaces, use str.strip():
sentence = ' hello apple'
sentence.strip()
>>> 'hello apple'