#!/usr/bin/env python3
# -*- coding : utf-8 -*-

# initialize a set , you must prepare a list first
# set can just save key , no value , no order
# no repeat keys in a set.

Set1 = set([1,2,3,4,5])
print('initialize',Set1)

# no repeat
Set2 = set([1,1,1,2,2,3,4,5])  # Accoring to pycharm notice , this function call can be replaced with set literal ,which
# means Set2 = {1,1,1,2,2,3,4,5}
print('no repeat',Set2)

# use set.add() to add something
Set1.add(8)
print('use add',Set1)
Set1.remove(3)
print('use remove',Set1)

# print two sets first
# set could do some calculation like and or
print('print set1',Set1)
print('print set2',Set2)
print('common',Set1 & Set2)  # show common keys
print('all',Set2 | Set1)  # add up and show all keys

# IMPORTTANT NOTICE : THE DIFFERENCE BETWEEN SET AND DICT IS WHETHER COULD SAVE VALUE LINKED WITH A KEY
# SET CANNOT , DICT CAN.
# SO SET AND DICT BOTH CANNOT INCLUDE CHANGEABLE FUNCTION

List1 = [15,68,79,29]
Set1.add(List1)
print('no changeable-list',Set1)

Tuple1 = (18,22,31,9)
Set2.add(Tuple1)
print('no changeable-tuple',Set2)