Question: 5) Like Q4 above, this time, the program counts the number of words that starts with a user-entered character. Instead of exiting after each entry,

5) Like Q4 above, this time, the program counts the number of words that starts with a user-entered character. Instead of exiting after each entry, a user can enter a letter repeatably until a 9 is entered Result string = It is very hot and humid in Memphis in the Summer but not in Seattle enter the character that you want to count in the string i there are 4 char "i" in the string try a different char, enter 9 to exit enter the character that you want to count in the string S there are 2 char "S" in the string try a different char, enter 9 to exit enter the character that you want to count in the string h there are 2 char "h" in the string try a different char, enter 9 to exit enter the character that you want to count in the string 9 done

Write a program to count the number of occurrences of a user-entered character within a string.

For this exercise, use the .split( ) method to create a list that each word is a list item.

Write a function (count (st, x) where st is the string, and x is the user-entered character

count(st, x) returns the number of occurrences of the character entered.

For example

st = "This is very hot and humid in Memphis"

x = user entered (using input( enter the character that you want to count in the string)

Pass this string (st) to count(st, x)

Result:

string = This is very hot and humid in Memphis

enter the character that you want to count in the string

h

there are 4 char "h" in the string

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!