SHARE
TWEET

Untitled

a guest Jan 21st, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. my_list = [3, 5, 5, 2, 8, 6, 6, 9, 3, 7]
  2.  
  3. def linear_search(my_list):
  4.     position = 0
  5.     while position < len(my_list):
  6.         print(my_list[position], "is at position", str(position))
  7.         if my_list[position] == 6:
  8.             print("Found at position", str(position))
  9.             return position
  10.         else:
  11.             position = position + 1
  12.     print("Not found")
  13.     return False
  14.  
  15. linear_search(my_list)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top