# A set contains unique elements of which the order is not important
s = set()
s.add(1)
s.add(2)
s.remove(1)
print(s)
# Can also be created from a list (or some other data structures)
num_list = [1,2,3]
set_from_list = set(num_list)
myNewSet = set()
myNewSet.add("what have you done")
myNewSet.add("to earn your place")
myNewSet.add("in this crowded world?")
"what have you done" in myNewSet # -> true
myNewSet.remove("to earn your place")
# -> myNewSet = {"what have you done", "in this crowded world?"}
set_example = {1, 2, 3, 4, 5, 5, 5}
print(set_example)
# OUTPUT
# {1, 2, 3, 4, 5} ----- Does not print repetitions
# Creating an empty set
b = set()
print(type(b))
## Adding values to an empty set
b.add(4)
b.add(4)
b.add(5)
b.add(5) # Adding a value repeatedly does not changes a set
b.add((4, 5, 6))
## Accessing Elements
# b.add({4:5}) # Cannot add list or dictionary to sets
print(b)
## Length of the Set
print(len(b)) # Prints the length of this set
## Removal of an Item
b.remove(5) # Removes 5 fromt set b
# b.remove(15) # throws an error while trying to remove 15 (which is not present in the set)
print(b)
print(b.pop())
print(b)
A_Set = {1, 2, "hi", "test"}
for i in A_Set: #Loops through the set. You only get the value not the index
print(i) #Prints the current value
list_1 = [1, 2, 1, 4, 6]
print(list(set(list_1)))
#help set the array in python in order
my_set = set() # Use this to declare an empty set in python
my_set = {"apple", "orange"} # Use this to declare a set in python
set_name = {item1, item2, ...}
#Definition: A collection of values (similiar spirit to python dictionary)
# implementing hash table as a data structure underneath the hood.