Вы можете использовать генератор с троичным выражением, чтобы проверить, буквенно-цифровые символы или нет:
import re
l = ['T', 'h', 'e', '/', ' * ', 's', 'k', 'y', ' * ', 'i', 's', '/', '/', 'b', 'l', 'u', 'e']
tmp = "".join(char if char.isalpha() else ' ' for char in l)
# This will put spaces where the * and / are
# then use regex to compress the spaces
mystr = re.sub('\s{2,}', ' ', tmp)
print(mystr)
Выходы: небо голубое
Затем, чтобы получить желаемый результат:
chars = []
not_capitalize = set(['is', 'and']) # you can put other words in here that you don't want to capitalize
# split will create an array of words split on spaces
for char in mystr.split():
if char in not_capitalize:
chars.append(char)
continue
# Separate the first letter from the rest of the word
first_letter, rest = char[0], char[1:]
# stitch the uppercase first_letter with the rest of the word together
chars.append("%s%s"% (first_letter.upper(), rest))
# join and print
print(' '.join(chars))
# Gives The Sky is Blue