Created
September 20, 2021 18:25
-
-
Save kiramishima/15f0b6712d65ea086d4bcf76f1cb5823 to your computer and use it in GitHub Desktop.
Mi solution ejercicio 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def MaxWord(parrafo, palabrasNoValidas): | |
parrafo2 = parrafo.lower() | |
expression = r'\w+' | |
res = re.findall(expression, parrafo2) | |
ocurrences = {} | |
for word in res: | |
if word not in palabrasNoValidas: | |
if word in ocurrences: | |
ocurrences[word] += 1 | |
else: | |
ocurrences[word] = 1 | |
print(ocurrences) | |
print(max(ocurrences, key=ocurrences.get)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment