

# longestName has two inputs, a list of names (one word each)
# and a letter. It returns the longest name that starts 
# with that letter. Assume all names start with a 
# capital letter and letter is a capital letter
def longestName(alist, letter):
    longest = ''
    for name in alist:
        if name[0] == letter:  # matches the letter
            if len(name) > len(longest): #longer
                longest = name
 #               print longest   # just to see


    return longest

# positionLongestName has the same two inputs. This
# returns the index position of the longest name
# that starts with letter
def positionLongestName(alist, letter):
    pos = -1
    longest = ''
    for index in range(len(alist)):
        name = alist[index]
        if name[0] == letter:  # matches the letter
            if len(name) > len(longest): #longer
                longest = name
                pos = index      
    return pos

#another version with enumerate
def positionLongestName2(alist, letter):
    pos = -1


               
    return pos


    
names = ['Fred', 'John', 'Sue', 'Joe', 'Mo', 'Sabrina', 'Mary', 'Sarah', 'Jackson']
print longestName(names,'J')
print positionLongestName(names, 'J')
print positionLongestName2(names, 'J')
print longestName(names,'S')
print positionLongestName(names, 'S')
print positionLongestName2(names, 'S')

