Question: Counting words in a string Write a function word_counter (input_str) which takes a string input_str and returns a dictionary mapping words in input_str to their

 Counting words in a string Write a function word_counter (input_str) which

Counting words in a string Write a function word_counter (input_str) which takes a string input_str and returns a dictionary mapping words in input_str to their occurrence counts. The keys must be inserted into the dictionary in the order in which they occur in the input string You may assume for this question that the list of words in input_str is just input_str.split) except that words must be converted to lower case at some point. For example Test Result word_count_dict word_counter("This is a sentence this is") 'this': 2, is:2, 'a': 1, sentence': 1) print(word_count_dict) ecord count_dict word-counter("AMORD is print (word_count_dict) word it is") {.a': 2, .uord.: 2, .is: 2, .it': 1}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!