Given a string S.
You have to return another string such that even-indexed and odd-indexed characters of S are grouped and groups are space-separated (see sample below)

Note: 
0 is considered to be an even index. 
All input strings are valid with no spaces


input:
'CodeWars'

output
'CdWr oeas'

S[0] = 'C'
S[1] = 'o'
S[2] = 'd'
S[3] = 'e'
S[4] = 'W'
S[5] = 'a'
S[6] = 'r'
S[7] = 's'


Even indices 0, 2, 4, 6, so we have 'CdWr' as the first group
odd ones are 1, 3, 5, 7, so the second group is 'oeas'
And the final string to return is 'Cdwr oeas'

Enjoy.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Sorting

Starter code: def sort_my_string(s):
	

Solutions:
def sort_my_string(s):
	return '{} {}'.format(s[::2], s[1::2])


def sort_my_string(S):
	return S[0::2] + ' ' + S[1::2]


def sort_my_string(s):
	return f'{s[::2]} {s[1::2]}'


def sort_my_string(s):
	(odd, even) = ([], [])
	for (i, char) in enumerate(s):
		even.append(char) if i % 2 == 0 else odd.append(char)
	return ''.join(even) + ' ' + ''.join(odd)


def sort_my_string(s):
	l = list(s)
	return ''.join(l[::2] + [' '] + l[1::2])


def sort_my_string(str):
	evenChar = str[::2]
	oddChar = str[1::2]
	return evenChar + ' ' + oddChar


sort_my_string = lambda w: w[::2] + ' ' + w[1::2]