Files
Laboratori-PY/indice.py
2024-03-22 17:01:42 +01:00

22 lines
354 B
Python

from sys import exit
from wordutils import clean
index = {}
try:
inf = open("indexdata.txt", "r")
except FileNotFoundError:
exit("File not found")
for line in inf:
fields = line.split(":")
key = fields[0].strip()
word = fields[1].strip()
if key not in index:
index[key] = set()
index[key].add(word)
print(index)