Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_list = [3, 5, 5, 2, 8, 6, 6, 9, 3, 7]
- def linear_search(my_list):
- position = 0
- while position < len(my_list):
- print(my_list[position], "is at position", str(position))
- if my_list[position] == 6:
- print("Found at position", str(position))
- return position
- else:
- position = position + 1
- print("Not found")
- return False
- linear_search(my_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement