dic.setdefault(key,[]).append(value)
Here is what the above code is Doing:
1. It’s creating a dictionary called dic.
2. It’s setting the default value of dic[key] to an empty list.
3. It’s appending value to the list.
dic.setdefault(key,[]).append(value)
Here is what the above code is Doing:
1. It’s creating a dictionary called dic.
2. It’s setting the default value of dic[key] to an empty list.
3. It’s appending value to the list.