In python, The function count_contains_x takes a list of strings (wordList) and returns the count of how many strings in the list contain at least one upper- or lower-case 'x'. Hint: Use the accumulator pattern to accumulate the count. Hint: You might want to use the string method count. For example: Test Result strlist = ["xerox", "OXEN", "whiffleball", "XOXOX"] print(count_contains_x(strlist)) 3 fish = ["angel", "gold", "cat", "puffer", "damsel"] print(count_contains_x(fish)) 0 strlist = ["X", "x"] print(count_contains_x(strlist)) 2 list_of_one_x = ["x"] print(count_contains_x(list_of_one_x)) 1
In python, The function count_contains_x takes a list of strings (wordList) and returns the count of how many strings in the list contain at least one upper- or lower-case 'x'. Hint: Use the accumulator pattern to accumulate the count. Hint: You might want to use the string method count. For example: Test Result strlist = ["xerox", "OXEN", "whiffleball", "XOXOX"] print(count_contains_x(strlist)) 3 fish = ["angel", "gold", "cat", "puffer", "damsel"] print(count_contains_x(fish)) 0 strlist = ["X", "x"] print(count_contains_x(strlist)) 2 list_of_one_x = ["x"] print(count_contains_x(list_of_one_x)) 1
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
Related questions
Question
In python, The function count_contains_x takes a list of strings (wordList) and returns the count of how many strings in the list contain at least one upper- or lower-case 'x'.
Hint: Use the accumulator pattern to accumulate the count.
Hint: You might want to use the string method count.
For example:
Test | Result |
---|---|
strlist = ["xerox", "OXEN", "whiffleball", "XOXOX"] print(count_contains_x(strlist)) | 3 |
fish = ["angel", "gold", "cat", "puffer", "damsel"] print(count_contains_x(fish)) | 0 |
strlist = ["X", "x"] print(count_contains_x(strlist)) | 2 |
list_of_one_x = ["x"] print(count_contains_x(list_of_one_x)) | 1 |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT