def searchInsert(nums, target): left = 0 right = len(nums)-1 while left<=right: mid = (left+right)//2 if target==nums[mid]: return mid # # left and right beside each other # elif right-left<=1: # # and target is inbetween (ie: [4,6], tar=5) # if target>=nums[left] and target<=nums[right]: # return left+1 # # target is outside of array (to the right) # elif target>nums[right]: # return right+1 # # target is outside of array (to the left) # elif targetnums[mid]: left = mid+1 elif target