From a sentence group all words that start with same alphabet and and sort it according to first character of the word
<p>suppose I take a string input from the user , and if will then group all the words in that sentence with respect  to first character of the word and later we have to display the o/p as dictionary , No repetition of words is allowed . 
For example consider i/p string <code>a="A cat ran after the dog and died due to injury"</code></p>

<p>Then o/p should be :</p>

<pre><code>{'A': ['A'], 'a': ['after', 'and'], 'c': ['cat'], 'd': ['died', 'dog', 'due'], 'i': ['injury'], 'r': ['ran'], 't': ['the', 'to']}
</code></pre>

<p>Here is making list according to starting character and all the words starting with that character . 
I have made this program :</p>

<pre><code>a="A cat ran after the dog and died due to injury"
b=[]
c={}
b=list(sorted(set(a.split())))
for x in b:
    e=x[0]
    c.setdefault(e,[])
    c[e].append(x)
print (c)
</code></pre>

<p>Can you suggest me different way to do this . I am not satisfied with this approach of mine . Please provide a algorithmic way .
The language I am using is python3</p>