#!/usr/bin/env python3 AtoZ = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] MaxDictionary = {} for i in AtoZ: MaxDictionary[i] = 0 #for i in AtoZ: # print (i, MaxDictionary[i]) # #print ("---------") SerialFile = open("SerNo.txt", "r") for ALine in SerialFile: char = ALine[0] NumAsString = ALine[1:] NumAsInt = int(NumAsString) #print( char, NumAsString, NumAsInt, ALine) CurrentMax = MaxDictionary[char] if NumAsInt > CurrentMax: MaxDictionary[char] = NumAsInt #print ("Max for " + char + " now " + str(NumAsInt)) for i in AtoZ: print (i, MaxDictionary[i])