Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def linsearch(lookingFor, mylist):
- counter = 1
- length = len(mylist)
- for each in mylist:
- if each == lookingFor:
- print("found at " + str(counter))
- return counter
- else:
- counter = counter + 1
- if counter = length:
- print("not found")
- return -1
- thislist = [12,32,13,213,12,3,23,21,312]
- whatToFind = 3
- linsearch(whatToFind, thislist)
Advertisement
Add Comment
Please, Sign In to add comment