Friday, July 31, 2009

Collection Types in Python 3

I would like to document some useful snippet for handling collections in Python 3.x.
set:

To add item to a set:

s.add(x)


To check whether item is in a set:
x in s #return True if set s contains item x


To remove item from a set:
s.remove(x)

No comments:

Post a Comment