Skip to content

Instantly share code, notes, and snippets.

@kiramishima
Created September 20, 2021 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiramishima/15f0b6712d65ea086d4bcf76f1cb5823 to your computer and use it in GitHub Desktop.
Save kiramishima/15f0b6712d65ea086d4bcf76f1cb5823 to your computer and use it in GitHub Desktop.
Mi solution ejercicio 1
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