Reverse every other word in a given string, then return the string. Throw away any leading or trailing whitespace, while ensuring there is exactly one space between each word. Punctuation marks should be treated as if they are a part of the word in this kata.

Difficulty: EASY
Starter code: def reverse_alternate(string):
	

Solutions:
def reverse_alternate(string):
	return ' '.join((y[::-1] if x % 2 else y for (x, y) in enumerate(string.split())))


def reverse_alternate(s):
	return ' '.join((w[::-1] if i % 2 else w for (i, w) in enumerate(s.split())))


def reverse_alternate(string):
	if string == '':
		return ''
	else:
		new_list = []
		for i in range(len(string.split())):
			if i % 2 != 0:
				new_list.append(string.split()[i][::-1])
			else:
				new_list.append(string.split()[i])
		return ' '.join(new_list)


def reverse_alternate(string):
	res = []
	arr = string.split()
	for i in arr:
		if arr.index(i) % 2 == 1:
			res.append(arr[arr.index(i)][::-1])
		else:
			res.append(arr[arr.index(i)])
	return ' '.join(res)


def reverse_alternate(s):
	words = s.split()
	words[1::2] = [word[::-1] for word in words[1::2]]
	return ' '.join(words)


def reverse_alternate(string):
	splitted = string.split()
	converted = []
	for elt in splitted:
		if splitted.index(elt) % 2 != 0:
			reversed = ''.join((char for char in elt[::-1]))
			converted.append(reversed)
		else:
			converted.append(elt)
	return ' '.join(converted)


def reverse_alternate(string):
	return ' '.join((j if i % 2 == 0 else j[::-1] for (i, j) in enumerate(string.split())))


def reverse_alternate(stg):
	return ' '.join((word[::-1] if i & 1 else word for (i, word) in enumerate(stg.split())))


def reverse_alternate(string):
	return ' '.join([word[::-1] if string.split().index(word) % 2 != 0 else word for word in string.split()])