import re
all = re.findall('\w+', 'hello there, hello again')
notAll = re.split('\s+', 'hello there, hello     again')

sentence = "One, two, three, four, five, let's go."
l = re.findall('[\w\']+', sentence)

def writeTest(filename, text):
    f = open(filename, "w")
    f.write(text)
    f.close()

def readTest(filename):
    f = open(filename)
    for line in f:
        print(line.strip())
    f.close()
    
def ship(filename, lst):
    f = open(filename, "w")
    for line in lst:
        f.write(line)
        if line[-1] != '\n':
            f.write('\n')
    f.close()
    
def ship2(filename, lst):
    f = open(filename, "w")
    f.writelines([s+'\n' for s in lst])
    f.close()def writeTest(filename, text):
    f = open(filename, "w")
    f.write(text)
    f.close()
    
# Sorting example with key function
def second(duple):
    return duple[1]

def sortEm(lst):
    return sorted(lst, key=second)

def testSort():
    print(sortEm([(4, 2), (10, 0), (20, 1)]))
