You are given a string of words (x), for each word within the string you need to turn the word 'inside out'. By this I mean the internal letters will move out, and the external letters move toward the centre. 

If the word is even length, all letters will move. If the length is odd, you are expected to leave the 'middle' letter of the word where it is. 

An example should clarify:

'taxi' would become 'atix'
'taxis' would become 'atxsi'

Difficulty: introductory

Starter code:

def inside_out(s):
	

Solutions:
import re

def inside_out(s):
    return re.sub(r'\S+', lambda m: inside_out_word(m.group()), s)

def inside_out_word(s):
    i, j = len(s) // 2, (len(s) + 1) // 2
    return s[:i][::-1] + s[i:j] + s[j:][::-1]

def swap(word):
    m = len(word) // 2
    if len(word) % 2 == 0:
        return word[:m][::-1] + word[m:][::-1]
    else:
        return word[:m][::-1] + word[m] + word[m+1:][::-1]
        
def inside_out(st):
    return ' '.join(map(swap, st.split()))

def inside_out(s):
    return ' '.join(w[:len(w)//2][::-1] + w[len(w)//2:(len(w)+1)//2] + w[(len(w)+1)//2:][::-1] for w in s.split())

from itertools import chain

def change(st):
    if len(st) < 4: return st
    q, r = divmod(len(st), 2)
    return ''.join(chain(st[q-1::-1], st[q:q+r], st[:q+r-1:-1]))

def inside_out(st):
    return ' '.join(map(change, st.split()))

def inside_out(st):
    def inside_out_1(st):
        h, m = divmod(len(st), 2)
        return st[:h][::-1] + st[h:h + m] + st[h + m:][::-1]
    return ' '.join(map(inside_out_1, st.split(' ')))

def inside_out(s):
    return ' '.join( w[:m][::-1] + w[m] * (L%2) + w[-m:][::-1] * (L>1)
                     if w else w
                     for w,m,L in map(lambda w: (w, len(w)//2, len(w)), s.split(' ')) )

inside_out=lambda s:" ".join([i[:len(i)//2][::-1] + ["",i[len(i)//2]][len(i)&1] + i[len(i)//2+(len(i)&1):][::-1] for i in s.split()])

def inside_out(text):
  return ' '.join(next(f'{w[:i][::-1]}{w[i:j]}{w[j:][::-1]}' for i, j in [[len(w)//2, (len(w)+1)//2]]) for w in text.split())

inside_out=lambda s:" ".join(x[:l][::-1]+x[l]*n+x[l+n:][::-1]for x in s.split()for l,n in[(len(x)//2,len(x)%2)])