Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def charWordList(wordList, char): - charWordList takes the parameter wordList the parameter char, and returns a list of all the strings that contain char. - If
def charWordList(wordList, char): - charWordList takes the parameter wordList the parameter char, and returns a list of all the strings that contain char. - If wordList is not a list type, or if char is not a string type, the function should return None. - If elements in wordList are not strings, those elements should just be ignored. - Note: When char is of type string, it will be of length 1. For example, char will be a single letter like "a" or "z. We will not test for cases where char is more than one character, like char = "ab - ***Hint: you will need to use a while loop, list indexing, and a call to your previous function. Once again, you may not use the in operator*** - ***Make sure to use charInWord function that you previously wrote: it is your helper function. *** return "stub" from labo3 import charWordList # Test cases for charWordList: def test_charWordList_1(): assert charwordList(["dog", "cat", "fish","wolf", "rabbit", "donkey"], "o") == ["dog", "wolf", "donkey"] def test_charWordList_2(): assert charWordList(["", 8, True, "groot", "grout"], "u") == ["grout"] def test_charWordList_3(): assert charWordList([""], "o") == [] def test_charWordList_4(): assert charWordList(["", 8, True, "groot", "grout"], True) == None
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started