Skip to content

Instantly share code, notes, and snippets.

@niranjrajasekaran niranjrajasekaran/set.py
Last active May 11, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.