This is a spin off of my first [kata](http://www.codewars.com/kata/56bc28ad5bdaeb48760009b0). You are given a list of character sequences as a comma separated string. Write a function which returns another string containing all the character sequences except the first and the last ones, separated by spaces. If the input string is empty, or the removal of the first and last items would cause the string to be empty, return a null value.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Starter code: def array(string):
	

Solutions:
def array(strng):
	return ' '.join(strng.split(',')[1:-1]) or None


def array(s):
	r = ' '.join(s.split(',')[1:-1])
	return r if r else None


def array(string):
	res = ' '.join(string.split(',')[1:-1])
	return res if len(res) > 0 else None


def array(string):
	if len(string) < 5:
		return None
	var = string.split(',')
	var = var[1:-1]
	s = ''
	for i in var:
		s += str(i) + ' '
	if s[:-1] == '':
		return None
	return s[:-1]


def array(str):
	l = len(str) > 2
	a = str.replace(' ', '').strip(',')
	b = a.split(',')
	c = b[1:-1]
	return ' '.join(c) if str and l and a and b and c else None


def array(string):
	return ' '.join(string.split(',')[1:-1]) or None


def array(s):
	return ' '.join(s.split(',')[1:-1]) or None


def array(string):
	split = string.split(',')
	remove = split[1:-1]
	return ' '.join(remove) if remove else None


def array(string):
	if len(string.split(',')) > 2:
		return str(' '.join(string.split(',')[1:-1]))


def array(string):
	s = string.replace(' ', '').split(',')
	return ' '.join(s[1:-1]) if s[1:-1] != [] else None


def array(string):
	newstring = string.strip().split(',')
	l = newstring[1:-1]
	s = ' '.join(l)
	if len(s) == 0:
		print(None)
	else:
		return s


def array(string):
	string = string.split(',')
	print(len(string))
	print(string)
	if len(string) <= 2:
		return None
	else:
		string = string[1:-1]
		print(string)
		return ' '.join(string)


def array(string):
	res = ' '.join(string.split(',')[1:-1])
	if not res:
		return None
	return res


def array(string):
	str_list = string.split(',')
	if len(str_list) < 3:
		return None
	str_list.pop(0)
	str_list.pop(len(str_list) - 1)
	return ' '.join(str_list) if str_list != '' else None


def array(string):
	numbers = string.split(',')
	return None if len(numbers) < 3 else ' '.join(string.split(',')[1:-1])


def array(string):
	str_slice = string.split(',')[1:-1]
	return ' '.join(str_slice) if str_slice else None


def array(string):
	x = string.split(',')
	if len(x) <= 2:
		return None
	else:
		x.pop()
		x.pop(0)
		return ' '.join(x)
print(array('1,2,3,4,5,6,7,8,9'))


def array(string):
	string = string.replace(' ', '')
	arr = string.split(',')
	return None if len(arr) < 3 else ' '.join(arr[1:-1])


def array(string):
	s = string.split(',')
	if len(s) >= 3:
		return ' '.join(s[1:-1])
	return


def array(string):
	array = string.split(',')[1:-1]
	new = ' '.join(array)
	return None if not new else new


def array(string):
	strlist = string.split(',')
	finalstr = ' '.join(strlist[1:-1])
	return finalstr if finalstr != '' else None


def array(st):
	st = st.replace(' ', '')
	arr = st.split(',')
	if len(arr) <= 2:
		return None
	return ' '.join(arr[1:-1])


def array(string):
	lst = string.split(',')
	if len(lst) < 3:
		return None
	lst.pop(0)
	lst.pop(-1)
	return ' '.join(lst)


def array(string):
	result = ''
	x = string.split(',')
	if len(x) < 3:
		return None
	else:
		for i in range(1, len(x) - 1):
			result += x[i] + ' '
		return result[:-1]


def array(string):
	rez = string.split(',')
	if len(rez) <= 2:
		return None
	s = ''
	for x in range(1, len(rez) - 1):
		s = s + rez[x] + ' '
	return s[:-1]


import numpy as np

def array(string):
	a = string.split(',')
	if len(a) <= 2:
		return None
	else:
		return ' '.join(a[1:len(a) - 1])


def array(string):
	first = -1
	last = -1
	for i in range(len(string)):
		if string[i] == ',' and first == -1:
			first = i
		if string[len(string) - i - 1] == ',' and last == -1:
			last = i
	if -last - 1 + len(string) == first or first == -1 or last == -1:
		return None
	return string.replace(' ', '').replace(',', ' ')[first + 1:-last - 1]


def array(string):
	a = list(string.split(','))
	if len(a) <= 2:
		return None
	else:
		return ' '.join(a[1:-1])


import re

def array(string):
	string = list(re.split(',| ', string))
	num = []
	for s in string:
		if s != '':
			num.append(s)
	if len(num) < 3:
		return None
	else:
		return ' '.join(num[1:-1])


import re

def array(string):
	l = re.sub(' ', '', string).split(',')
	if len(l) <= 2:
		return None
	else:
		return ' '.join(l[1:-1])


def array(string):
	l = string.split(',')
	if len(l) < 3:
		return
	return ' '.join((x.strip() for x in l[1:-1]))


def array(string):
	res = string.split(',')
	if len(res) < 3:
		return None
	res.pop()
	res.pop(0)
	return ' '.join(res)


def array(string=''):
	strings = string.split(',')
	return None if len(strings) < 3 else ' '.join([strings[i] for i in range(1, len(strings) - 1)])


def array(string):
	stripped_string_array = string.split(',')[1:-1]
	if len(stripped_string_array) == 0:
		return None
	return ' '.join(stripped_string_array)


def array(string):
	elems = list(map(str.strip, string.split(',')))
	if len(elems) < 3:
		return None
	return ' '.join(elems[1:-1])


def array(string):
	if string.count(',') > 1:
		return ' '.join(string.split(',')[1:-1]).strip()
	return None


def array(string):
	s1 = string.split(',')
	s2 = str(' '.join(s1[1:-1]))
	return s2 if s2 else None


def array(string):
	if string == '' or len(string) < 5:
		return None
	word = string.split(',')
	res = []
	for i in range(1, len(word) - 1):
		res.append(word[i])
	if len(res) < 1:
		return None
	else:
		return ' '.join(res)


def array(string):
	v = string.split(',')
	if len(v) > 2:
		v.pop()
		v.pop(0)
		return ' '.join(v)
	else:
		return None


def array(string):
	res = ' '.join(string.split(',')[1:-1])
	return res if res else None


def array(string):
	length = len(string.replace(' ', '').replace(',', ''))
	if length > 2:
		result = ' '.join(string.split(',')[1:-1])
		if result != '':
			return result
		else:
			return None


def array(string):
	x = ' '.join(string.split(',')[1:-1])
	if x:
		return x


def array(string):
	string_list = string.split(',')
	return ' '.join(string_list[1:-1]) if string_list[1:-1] else None


def array(string):
	string = ' '.join(string.split(',')[1:-1])
	if string:
		return string.strip()
	else:
		return None


def array(s):
	if len(s.split(',')) < 3:
		return
	else:
		return ' '.join(s.split(',')[1:-1])


def array(string):
	k = ' '.join(string.split(',')[1:-1])
	if k:
		return k
	else:
		return None


def array(string):
	arr = string.replace(' ', '').split(',')
	if len(arr) > 2:
		s = ''
		for x in arr[1:-1]:
			s = s + ' ' + x
		return s[1:]
	else:
		None


def array(string):
	x = string.split(',')
	y = x[1:-1]
	return None if len(x) < 3 else ' '.join(y)


def array(string):
	if len(string.split(',')) > 2:
		a = string.split(',')[1:-1]
		k = ''
		for c in a:
			k = k + c + ' '
		return k[:-1]
	else:
		return None


def array(string):
	x = string.split(',')
	r = None
	if len(x) > 2:
		r = ' '.join(x[1:-1])
	return r


def array(string):
	new = string.split(',')
	if string == '' or len(new) <= 2:
		return None
	else:
		new = new[1:len(new) - 1]
		new_str = ' '.join(new)
		return new_str


def array(s):
	arr = s.split(',')[1:-1]
	if arr == []:
		return None
	return ' '.join(arr)


def array(string):
	length = len(string)
	answer = ''
	if length == 0 or length == 1 or length == 3:
		answer = None
	else:
		x = 0
		comma = []
		while x < length:
			if string[x] == ',':
				comma.append(x)
			x = x + 1
		if len(comma) > 0:
			start = comma[0]
			stop = comma[-1]
			answer = string[start:stop + 1]
		answer = answer.replace(',', ' ')
		answer = answer[1:-1]
		if answer == '':
			answer = None
	return answer


def array(p):
	print(p)
	astring = ''
	s = p.replace(' ', '').split(',')
	print(s)
	if len(s) < 3:
		return None
	for i in range(0, len(s) - 1):
		if i == 0:
			pass
		else:
			astring += s[i] + ' '
	ansr = astring.rstrip()
	return ansr


def array(string):
	x = string.replace(' ', '').split(',')
	if len(x) < 3:
		return None
	return ' '.join(x[1:-1])


def array(s):
	arr = s.replace(' ', '').split(',')
	return None if len(arr) <= 2 else ' '.join(arr[1:-1])


def array(s):
	s = s.replace(',', ' ')
	s = s.split()
	if len(s) < 3:
		return None
	return ' '.join(s[1:-1])


def array(string):
	strings = string.split(',')
	del strings[0]
	if len(strings) > 0:
		del strings[len(strings) - 1]
	result = ''
	for i in strings:
		result = result + str(i) + ' '
	if len(result) > 0:
		return result.strip()
	else:
		return None


def array(string):
	string_to_list = string.split(',')
	remove_item = string_to_list[1:-1]
	result = ' '.join(remove_item)
	if result.isspace() is True or result == '':
		return None
	else:
		return result


def array(string):
	if len(string) <= 4 or len(' '.join(string.split(',')[1:-1])) == 0:
		return None
	else:
		return ' '.join(string.split(',')[1:-1])


def array(string):
	s = string.split(',')
	return None if len(s) < 3 else ' '.join((x for x in s[1:-1]))


def array(string):
	l = string.split(',')
	return None if not len(l) >= 3 else ' '.join(l[1:-1])


def array(string):
	s = string.split(',')
	s2 = ' '.join(s[1:len(s) - 1])
	return s2 if s2 is not '' else None


def array(string):
	print(string)
	if string.count(',') < 2:
		return None
	string = string.replace(',', ' ')
	front = 0
	for letter in string:
		front += 1
		if letter == ' ':
			break
	back = 0
	for letter in reversed(string):
		back += 1
		if letter == ' ':
			break
	return string[front:-back]


def array(string):
	x = string.replace(' ', '').split(',')
	return ' '.join(x[1:-1]) if len(x) > 2 else None


def array(s):
	m = s.split(',')
	if len(m) <= 2:
		return None
	return ' '.join(m[1:-1])


def array(string):
	new_string = string.split(',')
	results = ''
	for i in range(len(new_string)):
		if i != 0 and i != len(new_string) - 1:
			results += new_string[i] + ' '
	if not len(results):
		return None
	return results[0:-1]


def array(s):
	a = ' '.join(s.split(',')[1:-1])
	return a if a else None


def array(string):
	liste = string.split(',')
	if len(liste) > 2:
		liste.pop()
		return ' '.join(liste[1:])


def array(s):
	a = s.split(',')
	if len(a) > 2:
		return ' '.join(a[1:-1])


import re

def array(string):
	arr = re.split(',\\s*', string)
	if len(arr) < 3:
		return None
	return ' '.join(arr[1:-1])