As an exercise I have been tasked with writing a function that will check if a given container contains a searched value, returning True
if it does and False
if it doesn't. I have created the following function:
setContainer = {i for i in range(1000)}
listContainer = [i for i in range(1000)]
def does_it_contain(container, value):
if value in container:
return True
if value not in container:
return False
which works fine when I invoke the function explicitly.
However I am trying to add some code to let the user search for a value in the container of his choice like:
checkValue = input("Search for: ")
checkContainer = input("Seach in container named: ")
print(does_it_contain(checkContainer, checkValue))
But this seems to always yield False
, and I can't figure out why. Where have I gone wrong?