search(l, key):
if len(l) == 0:
return False
elif l[0] == key:
return True
else:
return search(l[1:], key)
I was just wondering if there is any way that i can get rid of "elif" statement. The function is suppose to return False if the key is not in the list "l" and True if otherwise. (it has to be a recursive function though)
And plus...
How would I modify this function so that it returns the index of key in l instead of True? (it still returns False if key is not in l)
I am not very good with computer programming...please someone help me? It would be greatly appreciated. =)
Thanks!