Question: STUCK ON A PART OF MY CODE '''Uses a binary search to locate rainfall amounts in mm from the supplied list of dictionaries. target is

STUCK ON A PART OF MY CODE

'''Uses a binary search to locate rainfall amounts in mm from the supplied list of dictionaries. target is a date in the 'yearmonth' value format. The function assumes that the list has been sorted by increasing date. The function will raise a ValueError exception if the year and month in target do not exist in allData.''' low = 0 high = len(allData) - 1 while low <= high : mid = (low + high) // 2 if target < allData[mid] : high = mid - 1 elif target > allData[mid] : low = mid + 1 else: return mid raise ValueError("Invalid")

Everytime I run this code, an error message pops up saying ' < not support between instances of 'int' and 'dict'. The problem is at 'target < allData[mid]' but I can't figure out how to fix it.

Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!