Write a Python function that takes two parameters: the first a list of strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False. Thank you.
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU
def listContainString(l,s):
for i in l:
if(i==s):
return True
return False
print(listContainString(["apple","banana","milk","egg"],"pumpkin"))
print(listContainString(["apple","banana","milk","egg"],"milk"))
Get Answers For Free
Most questions answered within 1 hours.