4 ms·
Python also supports dict and set comprehensions btw: { a : 2*a for a in range(1, 10)} #produces {1:2, 2:4, ...} { 2*a for a in range(1, 10)} #produce
by ThePhysicist 10y ago
Python also supports dict and set comprehensions btw:
{ a : 2*a for a in range(1, 10)} #produces {1:2, 2:4, ...}
{ 2*a for a in range(1, 10)} #produces set([2, 4, ...])
- xamuel 10y agoWish more people knew about dict comprehensions, it's maddening the contortions people go to because they don't know about it.