Assertion: set's element | /r/HasProperty | # output
Facets:
Source sentences:
text: # initialize my_set my_set = {1, 3} print(my_set) # if you uncomment line 9, # you will get an error # TypeError: 'set' object does not support indexing # my_set # add an element # Output: {1, 2, 3} my_set.add(2
text: # Difference between discard() and remove() # initialize my_set my_set = {1, 3, 4, 5, 6} print(my_set) # discard an element # Output: {1, 3, 5, 6} my_set.discard(4) print(my_set) # remove an element # Output: {1, 3, 5} my_set.remove(6) print(my_set) # discard an element # not present in my_set # Output: {1, 3, 5} my_set.discard(2) print(my_set) # remove an element # not present in my_set # you will get an error.