string=input('enter string:') new='' for i in string: if i!=' ': new+=i print('string after removing spaces:',new)