lesson_13_ex_2_17_18

def bathmologia(agwnes):
 scores = {}
 for i in agwnes:
    print i 
    tl=i.split(": ")
    tl1=tl[0].split("-")
    print tl , tl1
    if tl1[0] not in scores:
        scores[tl1[0]]=0
    if tl1[1] not in scores:
        scores[tl1[1]]=0
    tl2=tl[1].split("-")
    if int(tl2[0]) > int(tl2[1]):
        scores[tl1[0]] += 3
    elif int(tl2[0]) < int(tl2[1]):
        scores[tl1[1]] += 3
    else:
        scores[tl1[0]] += 1
        scores[tl1[1]] += 1
 return scores

agwnes = ['aa-bb: 3-1', 'aa-cc: 1-1', 'bb-cc: 0-2', 'cc-dd: 2-2', 'dd-aa: 2-1']
x = bathmologia(agwnes)
print x

 

Posted in Uncategorized