Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sort_search(sequence, value):
- sequence=sorted(sequence)
- position = 0
- for item in sequence:
- if value < item :#break if bigger item found
- print("False")
- break
- else:
- if value != item:
- position += 1
- if position == len(sequence): #if value is bigger than all items
- print("False")
- break
- else:
- print(item, "is at position", position, "of sorted sequence")
- break
- my_list = [5, 3, 7, 9, 2, 1]
- number = 9
- sort_search(my_list, number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement