title: Struggling with dictionaries
body: <p>I would appreciate it if somebody could help me solve the following exercise.</p>
  
  <p>Write a function that takes a string containing words separated by spaces and creates a dictionary where the keys correspond to the last characters of the words of the string, whilst the associated values correspond to the lists having the words ending in that character. </p>
  
  <p>Furthermore, the lists must be lexicographically sorted </p>
  
  <p>Example</p>
  
  <pre><code>string = "This will be an amazing experience"
  </code></pre>
  
  <p>Should return the following dictionary</p>
  
  <pre><code>{'s':['This'], 'l':['will'], 'e':['be', 'experience'], 'n':['an'], 'g':['amazing']}
  </code></pre>
  
  <p>I have an idea of how the exercise should be solved. However, given that i am still a beginner in Python, i struggle. </p>
  
  <p>The first thing i did is create an empty dictionary. Secondly, I converted the string of words into a list using the <strong>split</strong> method. Afterwards, i created another list that takes the last character of the words of the first list of strings and puts it into the new list.</p>
  
  <p>I used <strong>dict</strong> in order to put the elements of the second list as keys in my dictionary which works quite well. The problem is i cannot put the list of corresponding words as values.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>def dictionary (string):
  
      mydict = {}
      mylist = string.split()
      mylist2 = []
  
      for word in mylist:
  
          mylist2.append(word[-1])
          mydict = dict((el,(word[-1] for word[-1] in mylist)) for el in mylist2)
  
      return mydict
  </code></pre>