'''
name: Rafael STROHMAYER-DANGL
username: 20250067
file: text.py
'''
def main():
    path = input("Geben Sie den Pfad / Namen der Datei ein: ")
    print()
    print("--- Textanalyse ---")
    file = open(path)
    text = file.read()

    lines = 1
    words = 1
    letters = {}

    for i in range(len(text)):
        if text[i] == "\n":
            lines += 1
        if text[i].isspace() and not text[i-1].isspace():
            words += 1
        if text[i].isalpha():
            if text[i].lower() in letters:
                letters[text[i].lower()] += 1
            else:
                letters[text[i].lower()] = 1
    
    print(f"Zeilen: {lines}")
    print(f"Wörter: {words}")
    for i in letters:
        print(f"{i}: {letters[i]}")

main()