progName="sortF.py" #by D@ColeCanada #on 2023HAug01 #Purpose: to read a file into a Python list # removing the LineFeeds at end of each record # close the file # then sort the list # and print it # create empty list rList=[] #open the file containing records to be sorted f=open("fox.txt") for recWithLF in f: # remove the LF from each record rLen=len(recWithLF)-1 rec=recWithLF[0:rLen] #print("rec:",rec) if rec in rList: print("Error: record already exists:",rec) else: #append record to list rList.append(rec) #if end #for end #close the file f.close srList=sorted(rList) #sort the List #print the sorted list print("sorted srList:",srList) for r in srList:print(r)