Collections.namedtuple()

  • + 0 comments
    from collections import defaultdict
    n = int(input())
    k = defaultdict(list)
    header = list(map(str, input().split()))
    
    listed = []
    for x in range(n):
        listed.append(list(input().split()))
    
    for i, j in enumerate(header):
        for x in range(n):
            if (listed[x][i]).isnumeric():
                k[j].append(int(listed[x][i]))
            else:
                k[j].append(listed[x][i])
    
    print(f'{(sum(k.get('MARKS'))/n):.2f}')
    

    this works even they change colomn order