Guest User

Untitled

a guest
Jan 1st, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def linsearch(lookingFor, mylist):
  2. counter = 1
  3. length = len(mylist)
  4. for each in mylist:
  5. if each == lookingFor:
  6. print("found at " + str(counter))
  7. return counter
  8. else:
  9. counter = counter + 1
  10. if counter = length:
  11. print("not found")
  12. return -1
  13. thislist = [12,32,13,213,12,3,23,21,312]
  14. whatToFind = 3
  15. linsearch(whatToFind, thislist)
Advertisement
Add Comment
Please, Sign In to add comment