def my_title(s): words = str.split(s, ' ') twords = [] for w in words: #tw = str.upper(w[0]) + str.lower(w[1:]) tw = str.upper(w[:1]) + str.lower(w[1:]) list.append(twords, tw) #In one line: ## twords = [str.upper(w[:1]) + str.lower(w[1:]) \ ## for w in words] return str.join(' ', twords)