Question: Creates some function called FindToys that will accept two parameters an array called toys and the item that will be searched for in the list.

Creates some function called FindToys that will accept two parameters an array called toys and the item that will be searched for in the list. Call this second parameter search_item. Your function needs to return a boolean value that indicates whether the search_item was found.

As an example, if we have the following list called candy:

candy = ["snicker", "milky way", "almond joy", "skittles", "Kit Kat", "M & M"] 

and our search_item is 'almond joy', your function would return True meaning that your function found our item.

To start coding this open VS Code or IDLE. Create a function. To test your function use the following code. Place this code at that bottom of your file.

def main(): toys = ["ball", "doll", "bat", "puzzle", "legos", "Barbie", "truck"] search_item = "bat" found_item = bool #call search function found_item = FindToys(toys, search_item) print(found_item) main() 

If you print out True, then you can move just your function code only over to Codio for further testing.

Please note your code will be run by Codio using two different test cases. Make sure your code can accomodate a toys list that is smaller and/or larger than the one listed above. (HINT: use the len() function.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!