create 2d list dictionary

Solutions on MaxInterview for create 2d list dictionary by the best coders in the world

showing results for - "create 2d list dictionary"
Camilla
17 Apr 2019
1d = {}
2for elem in l:
3    if elem[1] in d:
4        d[elem[1]].append(elem[0])
5    else:
6        d[elem[1]] = [elem[0]]
7