Given a string, remove spaces from it. 
Example 1:
Input:
S = "geeks  for geeks"
Output: geeksforgeeks
Explanation: All the spaces have been 
removed.
Example 2:
Input: 
S = "    g f g"
Output: gfg
Explanation: All the spaces including
the leading ones have been removed.
Your Task:
You don't need to read input or print anything. Your task is to complete the function modify() which takes the string S as input and returns the resultant string by removing all the white spaces from S.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
Constraints:
1<=|S|<=10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3



class Solution:

    def modify(self, s):

        # code here

Solutions:
class Solution:

	def modify(self, s):
		return ''.join(s.split())


class Solution:

	def modify(self, s):
		return s.replace(' ', '')


class Solution:

	def modify(self, s):
		for i in s:
			if i == ' ':
				s = s.replace(i, '')
		return s


class Solution:

	def modify(self, s):
		ns = ''
		for e in s:
			if e == ' ':
				pass
			else:
				ns += e
		return ns


class Solution:

	def modify(self, s):
		s1 = ''
		for i in range(len(s)):
			if s[i] == ' ':
				pass
			else:
				s1 = s1 + s[i]
		return s1


class Solution:

	def modify(self, s):
		slen = len(s)
		word = ''
		for i in range(slen):
			if s[i] == ' ':
				continue
			else:
				word = word + s[i]
		return word


class Solution:

	def modify(self, s):
		lst = s.split()
		str = ''
		for i in lst:
			str += i
		return str


class Solution:

	def modify(self, s):
		return ''.join(map(str, s.split()))


class Solution:

	def modify(self, s):
		k = ''
		for i in range(len(s)):
			if s[i] != ' ':
				k = k + s[i]
		return k


class Solution:

	def modify(self, s):
		ns = ''
		for e in s:
			if not e.isspace():
				ns += e
		return ns


class Solution:

	def modify(self, s):
		m = s.split(' ')
		l = ''
		for i in m:
			l += i
		return l


class Solution:

	def modify(self, s):
		lst = list(s.split())
		return ''.join(lst)


class Solution:

	def modify(self, s):
		a = s.split()
		j = ''.join(a)
		return j


class Solution:

	def modify(self, s):
		res = ''
		for e in s:
			if e != ' ':
				res = res + e
		return res


class Solution:

	def modify(self, s):
		modified = ''
		for i in range(len(s)):
			if s[i] == ' ':
				continue
			modified += s[i]
		return modified


class Solution:

	def modify(self, s):
		S = ''
		v = ''
		for i in s:
			if i == ' ':
				v += i
			else:
				S += i
		return S


class Solution:

	def modify(self, s):
		result = ''
		for char in s:
			if char != ' ':
				result += char
		return result


class Solution:

	def modify(self, s):
		x = s.split(' ')
		t = ''.join(x)
		return t


class Solution:

	def modify(self, s):
		result = ''
		for i in s:
			if i != ' ':
				result += i
		return result


class Solution:

	def modify(self, s):
		w = s.strip()
		e = w.rstrip()
		f = e.replace(' ', '')
		return f


class Solution:

	def modify(self, s):
		ss = ''
		for i in s:
			if i != ' ':
				ss += i
		return ss


class Solution:

	def modify(self, s):
		ls = s.split(' ')
		st = ''
		for i in ls:
			st += i
		return st


class Solution:

	def modify(self, s):
		split_space = s.split()
		join_s = ''.join(split_space)
		return join_s


class Solution:

	def modify(self, s):
		str2 = ''
		for i in s:
			if i != ' ':
				str2 += i
		return str2


class Solution:

	def modify(self, s):
		list = s.split()
		ans = ''.join(list)
		return ans


class Solution:

	def modify(self, s):
		Lw = s.split()
		t = ''
		for wor in Lw:
			t += wor
		return t


class Solution:

	def modify(self, s):
		l = ''
		for i in s:
			if i == ' ':
				continue
			l = l + i
		return l


class Solution:

	def modify(self, s):
		result = ''
		for w in s:
			if w != ' ':
				result += w
		return result


class Solution:

	def modify(self, s):
		sr = ''
		for i in s:
			if i != ' ':
				sr += i
		return sr


class Solution:

	def modify(self, s):
		new = []
		for char in s:
			if char != ' ':
				new.append(char)
		return ''.join(new)


class Solution:

	def modify(self, s):
		a = list(s)
		ans = ''
		for i in a:
			if i == ' ':
				continue
			else:
				ans = ans + i
		return ans


class Solution:

	def modify(self, s):
		s = ''.join((a for a in s.lower() if a.isalpha()))
		return s


class Solution:

	def modify(self, s):
		q = ''
		for i in s:
			if i != ' ':
				q += i
		return q


class Solution:

	def modify(self, s):
		l = s.split()
		r = ''.join(l)
		return r


class Solution:

	def modify(self, s):
		list1 = ''
		for i in s:
			if i != ' ':
				list1 += i
		return list1