Skip to content

Instantly share code, notes, and snippets.

@nelix
Created July 5, 2009 04:49
Show Gist options
  • Save nelix/140842 to your computer and use it in GitHub Desktop.
Save nelix/140842 to your computer and use it in GitHub Desktop.
>>> d = {k:v for k,v in enumerate('ABCD') if v not in 'CB'}
>>> print(d)
{0: 'A', 3: 'D'}
>>> type(d)
<class 'dict'>
>>> s = {v for v in 'ABCDABCD' if v not in 'CB'}
>>> print(s)
{'A', 'D'}
>>> type(s)
<class 'set'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment