Question: Question 1: python Question 2: python python Dict Practice 1 Mr Cleese wants to know how many times a word appears in a sentence. Your
Question 1: python

Question 2: python

python
Dict Practice 1 Mr Cleese wants to know how many times a word appears in a sentence. Your task is to help him with it. Input Specification The first line will contain a single English sentence. All words will be lower case and separated by a single space. The second line will contain a single lowercased word. Output Specification The output should contain only integer, the number of times the inquired word has appeared in the sentence. Sample Input 1 canners can can what they can can can Sample Output 1 4 Dict Practice 2 This is the more advanced version of csci120p001 Mr Cleese wants to know how many times a word appears in a sentence. Your task is to help him with it. In addition, the words may not be separated from the punctuation marks. Here's a list of punctuation marks you might encounter: ".O.O.O.O.O.!? These symbols can occur anywhere in the text. (Hint: use str.replace(key." ") to get replace these with whitespace in the text) In addition, because the sentences might be written by silly people, expect irregular casings such as bellow: Copy What Is Up With That We IrD, New SpOnGeBOB Meme? (Hint: use str. lower() to get everything in lowercase. Input Specification The first line will contain a single English sentence. All words will be lower case and separated by a single space. The second line will contain a single lowercased word. Output Specification The output should contain only integer, the number of times the inquired word has appeared in the sentence. Sample Input 1 Copy Canners, cAn Can? "whAt They CAN CAN". can Sample Output 1 Copy 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
