Background
There is a message that is circulating via public media that claims a reader can easily read a message where the inner letters of each words is scrambled, as long as the first and last letters remain the same and the word contains all the letters.
Another example shows that it is quite difficult to read the text where all the letters are reversed rather than scrambled.
In this kata we will make a generator that generates text in a similar pattern, but instead of scrambled or reversed, ours will be sorted alphabetically
Requirement
return a string where:
1) the first and last characters remain in original place for each word
2) characters between the first and last characters must be sorted alphabetically
3) punctuation should remain at the same place as it started, for example: shan't -> sahn't
Assumptions
1) words are seperated by single spaces
2) only spaces separate words, special characters do not,  for example: tik-tak -> tai-ktk
3) special characters do not take the position of the non special characters, for example: -dcba  ->  -dbca
4) for this kata puctuation is limited to 4 characters: hyphen(-), apostrophe('), comma(,) and period(.) 
5) ignore capitalisation
for reference: http://en.wikipedia.org/wiki/Typoglycemia
import string

def find_char_index(word, mode='f'):
    word = [x for x in word]
    if mode == 'f':
        for index, char in enumerate(word):
            if char in string.punctuation:
                continue
            else:
                return index
    else:
        word.reverse()
        for index, char in enumerate(word):
            if char in string.punctuation:
                continue
            else:
                return len(word) - (index + 1)

def scramble_words(sentence):
    words = sentence.split(' ')
    final = []
    for word in words:

        first_index = find_char_index(word, 'f')
        last_index = find_char_index(word, 'l')
        
        res = ""
        ext_char = []
        for index, char in enumerate(word):
            if (char in string.punctuation) or (index == first_index) or (index == last_index):
                res += char
            else:
                res += "{}"
                ext_char.append(char)
        final.append(res.format(*sorted(ext_char)))

    return " ".join(final)



import string

def find_char_index(word, mode='f'):
    word = [x for x in word]
    if mode == 'f':
        for index, char in enumerate(word):
            if char in string.punctuation:
                continue
            else:
                return index
    else:
        word.reverse()
        for index, char in enumerate(word):
            if char in string.punctuation:
                continue
            else:
                return len(word) - (index + 1)

def scramble_words(sentence):
    words = sentence.split(' ')
    final = []
    for word in words:

        first_index = find_char_index(word, 'f')
        last_index = find_char_index(word, 'l')
        
        res = ""
        ext_char = []
        for index, char in enumerate(word):
            if (char in string.punctuation) or (index == first_index) or (index == last_index):
                res += char
            else:
                res += "{}"
                ext_char.append(char)
        final.append(res.format(*sorted(ext_char)))

    return " ".join(final)


