Skip to content
Snippets Groups Projects
L15T03.py 430 B
Newer Older
AB6912's avatar
AB6912 committed
import os
try:
    names = os.path.expanduser("~/") + "nimet.txt"
    n = open(names)
    names = n.readlines()
except:
    print("Epäonnistui!")
namedici = {}
for x in names:
    if x in namedici:
        namedici[x] = namedici[x] + 1
    else:
        namedici[x] = 1
nameslist = []
print("Nimiä on", len(namedici))
print("Esiintymät: ")
AB6912's avatar
AB6912 committed
dump = sorted(namedici)
for x in dump:
AB6912's avatar
AB6912 committed
    print(x, "esiintyy", namedici[x], "kertaa.")