Your task is to ___Reverse and Combine Words___. It's not too difficult, but there are some things you have to consider...

### So what to do?


Input: String containing different "words" separated by spaces

```
1. More than one word? Reverse each word and combine first with second, third with fourth and so on...
   (odd number of words => last one stays alone, but has to be reversed too)
2. Start it again until there's only one word without spaces
3. Return your result...
```

### Some easy examples:
```
Input:  "abc def"
Output: "cbafed"

Input:  "abc def ghi 123"
Output: "defabc123ghi"

Input:  "abc def gh34 434ff 55_eri 123 343"
Output: "43hgff434cbafed343ire_55321"
```

I think it's clear?! First there are some static tests, later on random tests too...

### Hope you have fun! :-)

Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures
Skill types: Data structures

Starter code:
def reverse_and_combine_text(text):
	

Solutions:
from itertools import zip_longest

def reverse_and_combine_text(text):
	words = text.split(' ')
	while len(words) > 1:
		it = map(lambda w: w[::-1], words)
		words = [a + b for (a, b) in zip_longest(it, it, fillvalue='')]
	return words[0]


def reverse_and_combine_text(s):
	while ' ' in s:
		res = s.split(' ')
		s = ''
		while res:
			s += res.pop(0)[::-1]
			s += res.pop(0)[::-1] if res else ''
			s += ' ' if res else ''
	return s


from itertools import zip_longest

def reverse_and_combine_text(text):
	ws = text.split()
	while len(ws) > 1:
		ws = [w1[::-1] + w2[::-1] for (w1, w2) in zip_longest(*[iter(ws)] * 2, fillvalue='')]
	return ws[0]


def reverse_and_combine_text(text):
	array = text.split(' ')
	while len(array) > 1:
		temp = []
		for i in range(0, len(array), 2):
			try:
				temp.append(array[i][::-1] + array[i + 1][::-1])
			except IndexError:
				temp.append(array[i][::-1])
		array = temp
	return ''.join(array)


def reverse_and_combine_text(stg):
	if not ' ' in stg:
		return stg
	words = [word[::-1] for word in stg.split()] + ['']
	result = ' '.join((f'{w1}{w2}' for (w1, w2) in zip(words[::2], words[1::2])))
	return reverse_and_combine_text(result)


def reverse_and_combine_text(s):
	if ' ' not in s:
		return s
	li = [i[::-1] for i in s.split()]
	return reverse_and_combine_text(' '.join((''.join(li[i:i + 2]) for i in range(0, len(li), 2))))


def reverse_and_combine_text(text):
	t = text.split()
	while len(t) > 1:
		t = [f'{a[::-1]}{b[::-1]}' for (a, b) in zip(*[iter([*t, ''])] * 2)]
	return t[0]


def reverse_and_combine_text(text):
	words = text.split()
	while len(words) > 1:
		words = [''.join((w[::-1] for w in words[i:i + 2])) for i in range(0, len(words), 2)]
	return ''.join(words)


from itertools import zip_longest

def reverse_and_combine_text(text):
	L = text.split()
	if len(L) == 1:
		return text
	return reverse_and_combine_text(' '.join((x[::-1] + y[::-1] for (x, y) in zip_longest(L[::2], L[1::2], fillvalue=''))))


def reverse_and_combine_text(text):
	lst = text.split(' ')
	if len(lst) == 1:
		return text
	while len(lst) != 1:
		lst1 = []
		for i in lst:
			a = ''.join(list(reversed(i)))
			lst1.append(a)
		lst2 = []
		if len(lst) % 2 == 0:
			for x in range(0, len(lst), 2):
				lst2.append(lst1[x] + lst1[x + 1])
			lst = lst2
		else:
			for x in range(0, len(lst) - 1, 2):
				lst2.append(lst1[x] + lst1[x + 1])
			lst2.append(lst1[-1])
			lst = lst2
	return lst[0]