4 ms·
Yes, in Python 2.7 onward: s = {i**2 for i in range(10) if i} and the colon is what makes the dict comprehension different from the set comprehension: d
by aaronchall 11y ago
Yes, in Python 2.7 onward:
s = {i**2 for i in range(10) if i}
and the colon is what makes the dict comprehension different from the set comprehension:
d - {i:i**2 for i in range(10) if i}