How would you implement a binary search algorithm?
Given a sorted list of integers and a target value, return the target's index or -1 if it is absent. Implement the search iteratively and return any valid index when duplicate target values exist.
binary_search(nums, target)-1def binary_search(nums, target):