# -*- coding: utf-8 -*- # Copyright (c) 2018, Silvio Peroni # # Permission to use, copy, modify, and/or distribute this software for any purpose # with or without fee is hereby granted, provided that the above copyright notice # and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE. my_first_set = set() # this creates a new set my_first_set.add(34) # these two lines add two numbers my_first_set.add(15) # to the set without any particular order # currently my_first_set contains two elements: # set({ 34, 15 }) my_first_set.set("Silvio") # a set can contains element of any kind # now my_first_set contains: # set({34, 15, "Silvio"}) my_first_set.remove(34) # it removes the number 34 # my_first_set became: # set({15, "Silvio"}) # it doesn't add the new elements since they are already included my_first_set.update(my_first_set) # current status of my_first_set: # set({15, "Silvio"}) my_first_set_len = len(my_first_set) # it stores 2 in my_first_set_len