Skip to content

Instantly share code, notes, and snippets.

@niranjrajasekaran
Last active May 11, 2019 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niranjrajasekaran/a39a0b736346327d07c60ac126fa1d2a to your computer and use it in GitHub Desktop.
Save niranjrajasekaran/a39a0b736346327d07c60ac126fa1d2a to your computer and use it in GitHub Desktop.
Basic implementation of python set
In [1]: s = {1, 2, 3, 4}
In [2]: type(s)
Out[2]: set
In [3]: s = {1, 10, 1, 3, 4}
In [4]: s
Out[4]: {1, 3, 4, 10}
In [5]: s[1]
TypeError Traceback (most recent call last)
<ipython-input-5-f8bb2b116405> in <module>() 1 s[1]
TypeError: 'set' object is not subscriptable
In [6]: for i in s:
...: print(i)
...:
1
10
3
4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment