Sets: A set is an unordered collection with no duplicate elements : Set In « Data Structure « Python






Sets: A set is an unordered collection with no duplicate elements

Sets: A set is an unordered collection with no duplicate elements


basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
fruit = set(basket)                     # create a set without duplicates
print fruit

print 'orange' in fruit                 # fast membership testing

print 'crabgrass' in fruit


           
       








Related examples in the same category