Answered step by step
Verified Expert Solution
Link Copied!

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. -

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"

///////////////////////////////////////////////////////////////////////////

The only loop can be used is while rather than for

////////////////////////////////////////////////////////////////////////

pls run the pytest

//////////////////////////////////////////////////////////////

from lab03 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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def charInWord(word, char):

if type(word)==str and type(char)==str: i = 0 while(i

/////////////////////////////////////////////////////////

this is previous function if needed

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago