Daftar Python menghapus spasi
for i in range(0,(len(list))):
x = str(list[i]).strip(' ')
list[i] = x
Vihaking
for i in range(0,(len(list))):
x = str(list[i]).strip(' ')
list[i] = x
a = " yo! "
b = a.strip() # this will remove the white spaces that are leading and trailing
>>> import re
>>> re.sub(' +', ' ', 'The quick brown fox')
'The quick brown fox'
"\n".join([s for s in code.split("\n") if s])
string=' t e s t '
print(string.replace(' ',''))