Hopefully you've had a chance to look through the course web site and followed instructions from last time
Let's go check it out and discuss in a little more detail
Run the following code examples. In the note section below, describe what this code does.
my_list = [35,66,70,5,42,10,12]
print(42 in my_list)
my_list = [35,66,70,5,42,10,12]
print(0 in my_list)
If you run this code by itself, it doesn't do anything. How can you get it to work like it is meant to?
def search_for(item, list_to_search_in):
result = item in list_to_search_in
return result
Rewrite the search_for function above so that it uses a loop and if statement rather than the list-contains operator (i.e., in). Note that you can still use the in operator if setting up a for loop, just don't directly use it to check if the item is in the list.
def search_for(item, list_to_search_in):
return False #you'll need to change this line after you get your loop and if statement working