Mj Cheruiyot
Jun 9, 2021

--

Remove First and Last Character Part Two: Codewars.

This is a spin off of my first kata. 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.

Solution:

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

--

--

Mj Cheruiyot

Analytics Engineer/ Data Enthusiast/ Lover of Technology