>>>listoflist s = [['a', 'first'], ['b', 'second'], ['a', 'next'], ['c', 'third'], ['b', 'last']]
>>> dd = {}
>>>for item in listoflists:
... dd.setdefault(i tem[0], []).append(item)
- The part which mentions 'item[0]' would be to have the first letter of each item in the list we created right ?
- what does the ' [ ] ' signify in this case ? Does it mean to have a null value for each key that we create for the dictionary and add/create the value associated with the key from the append method ?
Regards,
Sudip Bhattacharya
>>> dd = {}
>>>for item in listoflists:
... dd.setdefault(i tem[0], []).append(item)
- The part which mentions 'item[0]' would be to have the first letter of each item in the list we created right ?
- what does the ' [ ] ' signify in this case ? Does it mean to have a null value for each key that we create for the dictionary and add/create the value associated with the key from the append method ?
Regards,
Sudip Bhattacharya
Comment