Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEMS 1. Write a function called countLetters() that accepts a list of strings as the first argument, and a string that is one character long

image text in transcribed
PROBLEMS 1. Write a function called countLetters() that accepts a list of strings as the first argument, and a string that is one character long as the second argument. The funtion should PRINT (not return) the number of times that the character is present in the list of strings. However, your function should NOT care about case. So if the user is wants to count the number of 'e' letters in the list of strings, your function should count 'e' as well as 'E'. HINT: One way might be to convert all of the strings in the list to upper case. Then convert the character to search for to upper case as well. Once you've done that, you can count the number of times it appears. When your function prints the results, you should use a format string so that the outputted statement says something like: "The letter C appears 3 times." Examples: sports = ['Baseball', 'Soccer', 'HOCKEY', 'table tennis', 'Quidditch'] countLetters (sports, 'b') #Should print: The letter B appears 3 times. countLetters (sports, 'C') #Should print: The letter Cappears 4 times

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago