from collections import defaultdict
      
      def word_occurence(sentence):
          occurrence = defaultdict(int)
          for word in sentence.split():
              occurrence[word] += 1
          return occurrence
      

      Python language logo
      Word Occurrence

      Python
      WordOccurence
      HGV Public Cookbook

      Function to count the occurrences of all words in a sentence

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.