In [31]:
    
tstLst = []  # build an empty list
print(tstLst)
    
    
In [32]:
    
tstLst.append(9)
tstLst.append("Dog")
print(tstLst)
    
    
In [33]:
    
# adding lists together
tstLst += ["cat", 10, 18, "animal", "mouse"]   
tstLst = tstLst + ["snow", "999", 998]
print(tstLst)
    
    
In [34]:
    
tstLst.remove("cat") # throws an error if not found
print("tstLst after .remove('cat'): %s" %tstLst)
print("Poping this value: %s" %tstLst.pop())  # pops the last value off the top
print("Popping the 3rd value: %s" %tstLst.pop(2))
print(tstLst)
    
    
In [35]:
    
# to sort it, the list must all be the same type:
tstLst = [str(i) for i in tstLst]
print(tstLst)  # unsorted
tstLst.sort()
print(tstLst)  # note: .sort() mutates and returns None
               # if this cell throws an error, re-run previous cells before re-running it
    
    
In [37]:
    
# sorted returns a value, this example combines with list comprehensions and string functions
# previous cells concerted all values within the list to strings
sorted([i.lower() for i in tstLst if i.isnumeric() == False])  # note: upper case sorts ahead of lower case
    
    Out[37]:
In [39]:
    
tstLst.insert(1, "13")  # inserts after index 1 i original list
print(tstLst)
    
    
In [42]:
    
tstLst.reverse() # mutates original and returns None
print(tstLst)
    
    
In [3]:
    
var1 = {}
def test_var(var):
    print("Type %s: \nContent: %s" %(type(var), var))
test_var(var1)
    
    
In [4]:
    
testSet = set()  # build an empty set, note that var = {} builds an empty dictionary
test_var(testSet)
    
    
In [5]:
    
testSet.remove(9)  # want an error thrown if you try to remove what does not exist?  Use this one
    
    
In [43]:
    
testSet.discard(9)  # does not exist?  Don't want an error?  Use this one
    
In [44]:
    
testSet.add(8)
testSet.add(13)
testSet = testSet.union({7,14,15})
print(testSet)
    
    
In [45]:
    
testSet.intersection({1,2,3,4,5,6,7,8,9})
    
    Out[45]:
In [ ]:
    
# for future development ...
# demonstrate difference, symmetric_difference, etc ...