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