fork download
  1. paragraph = "This is a test paragraph. This paragraph will test the code."
  2. word_count = {}
  3. cleaned_paragraph = paragraph.replace('.', '').replace(',', '').lower()
  4. words = cleaned_paragraph.split()
  5. for word in words:
  6. word_count[word] = word_count.get(word, 0) + 1
  7. print(word_count)
Success #stdin #stdout 0.08s 14124KB
stdin
Standard input is empty
stdout
{'this': 2, 'is': 1, 'a': 1, 'test': 2, 'paragraph': 2, 'will': 1, 'the': 1, 'code': 1}