yourset = set([1,2,3]) yourset.add(4)
# Basic syntax: your_set.add(element) # Example usage: your_set = {'all', 'kinds', 'of', 'stuff'} your_set.add('wacky') print(your_set) --> {'of', 'all', 'kinds', 'stuff', 'wacky'}
thisset = {"apple", "banana", "cherry"} thisset.add("orange") print(thisset)
list1 = [1, 1, 2, 3, 4, 4, 5] set1 = set(list1) set1.add(6) # gets inserted in the set if it does not already exist set1.add(5) # gets ignored as it already exists in the set
# Create a set seta = {5,10,3,15,2,20} # Or setb = set([5, 10, 3, 15, 2, 20]) # Find the length use len() print(len(setb))
#help set the array in python in order
# set of letters GEEK = {6, 0, 4} # adding 1 GEEK.add(1) print('Letters are:', GEEK) # adding 0 GEEK.add(0) print('Letters are:', GEEK)