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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started