I have a list of string like
vals = ['a', 'b', 'c', 'd',........]
using vals, I would be making a request to a server with each vals[i]. The server would return me a number for each of the vals.
it could be 1 for 'a', 2 for 'b', 1 again for 'c', 2 again for 'd', and so on. Now I want to create a dictionary that should look like
{ 1: ['a','c'], 2:['b','d'], 3: ['e'], ..... }
What is the quickest possible way to achieve this? Could I use map() somehow?
I mean I can try doing this by storing the results of request in a separate list and then map them one by one - but I am trying to avoid that.