feat: Initial commit

This commit is contained in:
2024-03-22 17:01:42 +01:00
parent 954985f39a
commit c343ff6e93
106 changed files with 143428 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
def clean(word: str):
a = len(word)
while True:
word = word.strip("()[]{}!?.,<>:;-_`")
if a == len(word):
break
a = len(word)
return word
def main():
filename = input("Inserisci il nome del file: ")
fio = open(filename, "r")
words = {}
for line in fio:
for word in line.split():
word = clean(word)
if word not in words:
words[word] = 1
else:
words[word] += 1
fio.close()
vals = sorted(words.values(), reverse=True)
for i in range(0, 100):
for word in words:
if words[word] == vals[i]:
print(word, end=" ")
words.pop(word)
break
print()
main()