Making dictionary construction shorter in Python using defaultdict? -


is there anyway can make code-block shorter? seems written more efficiently:

combs = defaultdict(list) zf in zipfiles:     chunks = zf.split('_')     combs[chunks[0] + '_' + chunks[1]].append(zf) 

maybe searching this:

combs = defaultdict(list) zf in zipfiles:     combs["_".join(zip.split("_")[0:2]].append(zf) 

Comments

Popular posts from this blog

javascript - Trigger mouseenter when an animated element touches mouse -

json - Zend error Connection -

java - Using Spring @Transactional with a combination of readOnly and write, when does this entity get committed? -