This program will search a list for a give value. Python...
def searchList(inList, val):
hit = false
For x in inList:
if x == val:
hit = true
return hit
This function will always return the correct value as it looks through the entire list. It will also complete in finite time because it compares each value once.
No comments:
Post a Comment