AttributeError: ‘list’ object has no attribute ‘keys’

Open source software supply chain lighting plan, waiting for you>>>

#encoding=utf-8
import os


result = {}
if os.path.exists("test.txt"):
    day_file = open("test.txt").read()
    day_file_list = day_file.split(" ")

    for i in day_file_list:
                #   print "i: s" + str(i) + "e"
        if i == "#" or " ":
            day_file_list.remove(i)
                        #continue
            if i not in result:
                result[i] = 1  
            else:
                result[i] = result[i] + 1
                #   print "result i: " + str(result[i])

result = sorted(result.items(), key = lambda item: item[1], reverse=True)


for k in result.keys():
    print result[k]

Solution:

for i in result:
    print i

Similar Posts: