Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Below is the bugged version of find_element(). Find and fix the bug! def find_element(word, word_list): idx_list = [] for idx in range(len(word_list)): if word
# Below is the bugged version of find_element(). Find and fix the bug!
def find_element(word, word_list): idx_list = [] for idx in range(len(word_list)): if word in word_list[idx]: idx_list.append(idx) return idx_list
Practice using test cases to debug a function. This is the same function we developed earlier in the iterative development lesson. It is a function that takes as arguments a string and a list of strings, and returns the a list of indices where the first string was found in the list. It is to be case insensitive and handle partial words as well. Check back in 5.2 for more complete definition. Find the error in this version of that code and fix it. Hint: is some functionality missing? Sample Input 1: cot ['cot', 'COT', 'CAT', 'cinch'] Sample Output 1: [0, 1] Sample Input 2: a ['apple', 'banana', 'orange', 'cherry'] Sample Output 2: [0, 1, 2]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