Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- numbers =[random.randint(1,30) for x in range(1,21)]
- alist = sorted(numbers)
- print(alist)
- def linear_search(alist, value):
- for position, item in enumerate(alist):
- if item == value:
- print(item, 'is in position', str(position))
- break
- if item > value:
- print('item is not found in alist')
- break
- linear_search(alist, 9)
Advertisement
Add Comment
Please, Sign In to add comment