
def up_low(strings):
    new_strings = []
    for i in range(len(strings)):
        if strings[i][0].isupper():
            strings[i] = strings[i].upper()
        else:
            strings[i] = strings[i].lower()


l1 = ['Ben', 'ben', 'jOSEph', 'JAmeS']
up_low(l1)
print(l1)
l1 = ['aAAAA', 'Bbbbb', 'CcCc', 'dDdD']
up_low(l1)
print(l1)

def char_length(strings):
    length = 0
    for s in strings:
        length += len(s)
    return length

def longest(first, second):
    length_1 = char_length(first)
    length_2 = char_length(second)
    if length_1 > length_2:
        return 1
    elif length_1 < length_2:
        return 2
    return 3


l1 = ['this is a string!']
l2 = ['a', 'b', 'c']
print(longest(l1, l2))

l1 = ['one', 'two', 'three']
l2 = ['four', 'five', 'six']
print(longest(l1, l2))

l1 = ['Joe', 'Reed']
l2 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
print(longest(l1, l2))


def check_ok_applicants(names, ages, educs):
    allowed = []
    for i in range(len(names)):
        if ages[i] >= 27 and ages[i] < 50:
            if educs[i] == 'MS' or educs[i] == 'BS' or educs[i] == 'PhD':
                allowed.append(names[i])
    return allowed


names = ['Bob', 'Anna', 'Martha', 'Marty', 'Kate', 'Karen', 'Chris', 'Jane']
ages = [24, 19, 23, 34, 23, 30, 70, 51]
educs = ['MS', 'HS', 'NA', 'MS', 'NA', 'BS', 'PhD', 'MS']
print(check_ok_applicants(names, ages, educs))

def remove_triples(content):
    removals = 0
    i = 1
    length = len(content)
    while i < length-1:
        if content[i] == content[i-1] and content[i] == content[i+1]:
            del content[i]
            del content[i]
            removals += 1
            i -= 1
        i += 1
        length = len(content)
    return removals

content = [1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 8, 8]
print(remove_triples(content))
print(content)

content = [5, 5, 5, 5, 5, 5, 5]
print(remove_triples(content))
print(content)


